matlab绘图plot常用设置

目录

图像的大小和位置

一个窗口画多张子图片

保存图片


图像的大小和位置

MATLAB 中设置 Figure 和 Axes 的位置和尺寸 – 知乎 (zhihu.com)matlab绘图plot常用设置https://zhuanlan.zhihu.com/p/446968474示例:

plot(t,y, ‘Color’, [0,0,1],’Linewidth’,1.5);
set(gca,’Position’, [.13 .60 .80 .30]);

set(gca,’linewidth’,1.2,’fontsize’,14,’fontname’,’Times’);

xlim([0 2.5]);

ylim([-0.1 0.1]);

legend({‘Heave Position’});

title(‘Trajectory 1 Heave Motion’);

xlabel(‘Time (s)’);

ylabel(‘Heave(m)’);

matlab绘图plot常用设置

一个窗口画多张子图片

(25条消息) Matlab如何在一个窗口绘制多张子图_matlab一个窗口画多个图_沉沙丶的博客-CSDN博客matlab绘图plot常用设置https://blog.csdn.net/sy243772901/article/details/115541794(26条消息) Matlab调整子图位置及大小_matlab设置画布大小_Lu_gl的博客-CSDN博客matlab绘图plot常用设置https://blog.csdn.net/Lu_gl/article/details/125875757

示例:

%上图

subplot(2,1,1)

plot(t,y, ‘Color’, [0,0,1],’Linewidth’,1.5);

set(gca,’linewidth’,1.2,’fontsize’,14,’fontname’,’Times’);

xlim([0 2.5]);

ylim([-0.1 0.1]);

legend({‘Heave Position’});

title(‘Trajectory 1 Heave Motion’);

xlabel(‘Time (s)’);

ylabel(‘Heave(m)’);

%下图

subplot(2,1,2)

plot(t,y2 /pi, ‘Color’, [1,0,0],’Linewidth’,1.5);

set(gca,’linewidth’,1.2,’fontsize’,14,’fontname’,’Times’);

xlim([0 2.5]);

ylim([-0.65 0.25]);

legend({‘Pitch angle (nomalized by pi)’});

title(‘Trajectory 2 Pitch Motion’);

xlabel(‘Time (s)’);

ylabel(‘Angle’);

matlab绘图plot常用设置

保存图片

print函数

使用plot函数后紧接着用print函数来保存图像。print的格式为: print(figure_handle,fileformat,filename),其中的三个参数:

(1)figure_handle:图形句柄,如果图形窗口标题栏是“Figure 3”,则句柄就是3;也可以直接用gcf获取当前窗口句柄

(2)fileformat:单引号字符串,指定存储格式:

png格式: ‘-dpng’

jpeg格式: ‘-djpeg’,

tiff格式: ‘-dtiff’

bmp格式: ‘-dbitmap’

gif格式:’-dgif’

emf无损格式:’-dmeta’

(3)filename:’文件名’

批量保存图片示例:

name=[‘轨迹1_’,num2str(k)];

print(gcf,’-dpng’,name);

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/89423228b8.html