matlab刻度字体,matlab 自动保存画图和坐标轴刻度字体设置

利用matlab计算出的数据,画出图形,然后再保存到某个目录下。为了省事,想利用命令直接设置图形的相关内容。

下面的程序段可供参考:

x=linspace(1,2,10)

plot(x,'--pr','linewidth',1.5,'MarkerEdgeColor','r','MarkerFaceColor','m','MarkerSize',10)

legend('x','Location','best')

title('x','FontName','Times New

Roman','FontWeight','Bold','FontSize',16)

xlabel('T','FontName','Times New

Roman','FontSize',14)

ylabel('X','FontName','Times New

Roman','FontSize',14,'Rotation',0)

axis auto equal

set(gca,'FontName','Times New

Roman','FontSize',14)

1、坐标轴范围设置:

a. axis([xmin xmax ymin ymax])设置坐标轴在指定的区间

b.

只设置x轴在指定区间,set(gca,'xlim',[0 1]);

c.

只设置y轴在指定区间,set(gca,'ylim',[0 1]);

2、坐标轴刻度设置

set(gca, ’XTick’, [0 1 2]) X坐标轴刻度数据点位置

set(gca,'XTickLabel',{'a','b','c'})

X坐标轴刻度处显示的字符

set(gca,'FontName','Times New

Roman','FontSize',14)设置坐标轴刻度字体名称,大小

‘FontWeight’,’bold’ 加粗 ‘FontAngle’,’italic’

斜体

对字体的设置也可以用在title, xlabel, ylabel等中

3、图例

legend('a','Location','best') 图例位置放在最佳位置

4、坐标轴标注,标题

xlabel('$\tau$','interpreter','latex','FontName','Times','FontSize',16);

ylabel('$\vartheta_3$','interpreter','latex','FontName','Times','FontSize',16);5、保存图片

filename=[string,num2str(Omega_0),string];

print('-depsc2', '-adobecset', '-tiff', '-cmyk','-r2000',

[filename, '.eps']);