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

P.S. 我用的Matlab2017a没有NumColumns属性,想要排列为几行几列可以参考:https://zhidao.baidu.com/question/624168427868739764.html


 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"})

导出为高清图:图中文件--导出设置--渲染--分辨率--600--保存--应用于图形--确定

posted @ 2019-05-09 13:09  Keegen  阅读(1009)  评论(0)    收藏  举报