How to change font size of x axis? [closed]

别来无恙 提交于 2019-11-29 08:18:05
Marc Manzano

I always do it in the following way:

plot(X)
set(gca, 'FontName', 'Arial')
set(gca, 'FontSize', 12)
ylabel('Label Y axis')
xlabel('Label X axis')

In this way, the axis and the label will have the requested font and size. It is important to put 'xlabel' and 'ylabel' after the 'set'. The order in this case matters.

There is other way to set the fonts for the xlabel, ylable, legend, plot as below; it may complement the upper answer:

% Define values
linewidthnumber = 2;
legendfontsize = 12;
labelfontsize = 12;
axisfontsize = 12;
custom_plot_handle_name = plot(x);
custom_legend_handle_name = legend();
custom_x_label_name = xlabel();
custom_y_label_name = ylabel();

% Set the parameters now to the given values
set(h, 'Linewidth', linewidthnumber);
set(custom_legen_handle_name,'FontSize', legendfontsize);
set(custom_x_label_name, 'FontSize', labelfontsize);
set(custom_y_label_name, 'FontSize', labelfontsize);
set(gca, 'FontSize', axisfontsize);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!