Matlab最实用画图命令整理
全部手码,自己整理,走过路过点个赞收藏一下吧!
最近在写论文,SCI需要300dpi以上的高清图(见第6部分用Print输出高清图),用matlab导出图的时候,碰到一些问题,就整理了一下,希望能帮助到大家。代码整理如下:
1、关于 gcf 和 gca
gcf = Current figure handle 当前图形的句柄
fig = gcf; % returns the current figure handle.
gca = Get handle to current axis. 获取当前图形坐标轴的句柄
H = gca; % returns the handle to the current axis in the current figure.
% The current axis is the axis that graphics commands like PLOT, TITLE, SURF, etc. draw to if issued.
% Use the commands AXES or SUBPLOT to change the current axis to a different axis, or to create new ones.
2、画多个子图(subplot),以4个子图为例
在写论文的过程中,会涉及到多个图的情况,大致整理如下:
figure,
subplot(2,2,1),plot(x,y1,y2,'linewidth',2);
% subplot('position', [0.11 0.63 0.35 0.3]); % [x0 y0 width height] 可以设置位置,一般默认即可
% 左下角为原点,横向为x,竖向为y
% figure在画布中的位置由 ‘Position’, [x0 y0 Width Height] 设置
title('a'); %设置图标题
xlabel('{Time(s)}'),ylabel('{Slant range(km)}'); %X轴和Y轴名称,单位
legend('one','two'); %几个y对应legend括号里面几个元素,单个曲线不需要legend
axis([0 2 60 400]); %设置横纵坐标的范围,可不设置,默认
xticks(0:0.2:2); %这样x轴会每隔0.2显示一个刻度,可不设置,默认
yticks(60:20:400); %这样y轴会每隔20显示一个刻度,可不设置,默认
set(gca,'FontSize',20); %设置字体大小,20在PPT中比较合适,放在论文中一般8号就好了
subplot(2,2,2),plot(x2,y2); %后面的子图和前面一样
title('b');%设置图标题
% ...
subplot(2,2,3),plot(x3,y3);
title('c');%设置图标题
% ...
subplot(2,2,4),plot(x4,y4);
title('d');%设置图标题
% ...
3、关于figure的一些设置命令整理
设置曲线线宽、标记点大小,标记点边框颜色和标记点填充颜色等。
plot(…,’Property Name’, Property Value, …)

本文全面解析Matlab绘图核心技巧,涵盖gcf和gca句柄使用、子图布局、figure设置、坐标轴调整、imagesc函数及高清图像输出。通过详细代码示例,助你掌握高质量学术图表制作。
最低0.47元/天 解锁文章
2968

被折叠的 条评论
为什么被折叠?



