文章目录
1 添加标题2 添加轴标签 3 添加图例 4 更改标题、标签、图例的字体大小1 添加标题
title
:向图中添加标题
示例:
clc;clear;% 绘制x = linspace(0,2*pi);y = sin(x) - tan(sin(x));plot(x,y)title('y = sin(x)-tan(sin(x))')
结果展示:
2 添加轴标签
xlabel
:x轴标签
ylabel
:y轴标签
zlabel
:z轴标签(plot3)
示例:
clc;clear;% 绘制x = linspace(0,2*pi);y = sin(x)-tan(sin(x));plot(x,y)title('y = sin(x) - tan(sin(x))')xlabel('X(m)')ylabel('Y(m)')
结果展示:
3 添加图例
legend
:按绘图顺序添加图例
示例:
clc;clear;% 绘制x = linspace(0,2*pi);y = sin(x)-tan(cos(x));plot(x,sin(x))hold onplot(x,cos(x))hold onplot(x,tan(cos(x)))hold onplot(x,y)hold offtitle('添加图例')xlabel('X(m)')ylabel('Y(m)')% 按绘图顺序添加图例legend('y = sin(x)','y = cos(x)','y = tan((cos(x))','y = sin(x) - tan(cos(x))')
结果展示:
4 更改标题、标签、图例的字体大小
'FontSize'
字号属性
示例:
clc;clear;% 绘制x = linspace(0,2*pi);y = sin(x)-tan(cos(x));plot(x,sin(x))hold onplot(x,cos(x))hold onplot(x,tan(cos(x)))hold onplot(x,y)hold offtitle('添加图例','FontSize',20)xlabel('X/(m)','FontSize',15)ylabel('Y/(m)','FontSize',10)% 按绘图顺序添加图例legend('y = sin(x)','y = cos(x)','y = tan((cos(x))','y = sin(x) - tan(cos(x))')
结果展示:
相关链接
/help/matlab/creating_plots/add-title-axis-labels-and-legend-to-graph.html
如果觉得《MATLAB:添加图标题 轴标签 图例 更改字体大小》对你有帮助,请点赞、收藏,并留下你的观点哦!