Matlab画图常用

Matlab画图包括标题、标签、图例等,还包括坐标轴的处理,如坐标轴翻转,坐标轴范围改变等。

参考:https://ww2.mathworks.cn/help/matlab/titles-and-labels.html?s_tid=CRUX_lftnav

标题和标签:


 title

title(titleName,Name,Value)     %Name属性名,Value属性值。常见属性有:color、fontsize、fontweight、fontname(字体)

创建多行标题:

title({'First line';'Second line'})

在每个子图上添加标题:

1 s(1) = subplot(2,1,1);
2 plot(...)
3 s(2) = subplot(2,1,2);
4 plot(...)
5 title(s(1),'Top Plot')
6 title(s(2),'Bottom Plot')

 xlabel、ylabel

与title差不多。


 legend

legend({'cos(x)','cos(2x)','cos(3x)','cos(4x)'},'Location','northwest','NumColumns',2,name,value)     %'location'指定位置,'numcolumns'指定图例有多少列,name,value属性(用法和title差不多),字体颜色属性用textcolor

 xlim、ylim

设置x、y坐标显示范围


 grid on

打开网格 


 y坐标翻转

set(gca,'ydir','reverse')

 x、y坐标数值显示改变

1 set(gca,'xtick',[1,3,5,7])
2 set(gca,'xticklabel',{"one","three","five","seven"})

猜你喜欢

转载自www.cnblogs.com/keegentang/p/10837884.html
今日推荐