matlab绘图总结

1.怎样在坐标轴上设置自定义的标签

答:set(gca,'XTickLabel',{'FD001','FD002','FD003','FD004'});% 设置其余坐标区属性

2.用text()显示plot函数的坐标点

(转:Matlab代码之plot函数的坐标点显示_横冲直撞de的博客-CSDN博客_matlab plot显示数据点

//
clc;clear;close all;
x=1:8;
y1=x+2;
figure;subplot(1,2,1);plot(x,y2,'-*');title('图2:显示函数坐标点形式一');
xlabel('x');ylabel('y2');
str1=num2str(y2');text(x,y2,str1);
%文件名不能与matlab内置函数同名,不然运行失败。

subplot(1,2,2);plot(x,y2,'-*');title('图3:显示函数坐标点形式二');
xlabel('x');ylabel('y2');
for i=1:8
text(x(i),y2(i),['(',num2str(x(i)),',',num2str(y2(i)),')']);
end
%第二种形式的第二种表达方法
%str=[repmat('(',size(x,2),1),num2str(x') ...
%repmat(', ',size(x,2),1),num2str(y2'),repmat(')',size(x,2),1)]; 
%text(x,y2,cellstr(str));

 3.MATLAB绘制条形图并显示数值

转自:MATLAB绘制条形图并显示数值_zhangsangood的博客-CSDN博客_matlab柱状图显示数据

x = 2012:1:2020;
y = [1, 4, 2, 8, 49, 122, 358, 859, 1477];
b = bar(x, y, 0.6) %0.6表示条形图宽度,可修改
xlabel('年份')
ylabel('数值')
set(gca,'ylim',[0,1600],'ytick',[0:200:1600]); %纵坐标数值为0到1600,每隔200显示刻度
set(gca, 'Ygrid','on'); %纵坐标刻度显示网格
xtips1 = b.XEndPoints;
ytips1 = b.YEndPoints; %获取 Bar 对象的 XEndPoints 和 YEndPoints 属性
labels1 = string(b.YData); %获取条形末端的坐标
text(xtips1,ytips1,labels1,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom')
%将这些坐标传递给 text 函数,并指定垂直和水平对齐方式,让值显示在条形末端上方居中处

4.Matlab 图例 位置的不同命令

Matlab位置选择
一个简单的表格是这么创建的:

转自:Matlab 图例 位置的不同命令_VS洗发水的博客-CSDN博客_matlab图例位置

设置位置
‘North’inside plot box near top
‘South’inside bottom
‘East’inside right
‘West’inside left
‘NorthEast’inside top right (default for 2-D plots)
‘NorthWest’inside top left
‘SouthEast’inside bottom right
‘SouthWest’inside bottom left
‘NorthOutside’outside plot box near top
‘SouthOutside’outside bottom
‘EastOutside’outside right
‘WestOutside’outside left
‘NorthEastOutside’outside top right (default for 3-D plots)
‘NorthWestOutside’outside top left
‘SouthEastOutside’outside bottom right
‘SouthWestOutside’outside bottom left
‘Best’least conflict with data in plot
‘BestOutside’least unused space outside plot
Enable Ginger Cannot connect to Ginger Check your internet connection
or reload the browserDisable in this text fieldRephraseRephrase current sentence 0Edit in Ginger×
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

舞动的白杨

客官,可否打赏UP主喝杯咖啡?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值