1. 设置坐标轴上下限:
axis([xmin,xmax,ymin,ymax]);
例:axis([0, 11, 0, 0.5]); xmin = 0, xmax = 11, ymin = 0, ymax = 0.5;
2、坐标轴名称相关设置:
x轴的名称及字体和大小:xlabel('x(m)', 'FontName', 'Times New Roman', 'FontSize', 7);
例:xlabel('n','FontName','Times New Roman','FontSize', 22);
3、坐标轴的字体及大小设置:
set(gca,'FontName','Times New Roman','FontSize',7,'LineWidth',1.5);
例:set(gca,'FontName','Times New Roman','FontSize', 18, 'LineWidth',0.5);
4、 图例的相关设置:
图例中字体及大小:legend('FontName','Times New Roman','FontSize',7,LineWidth',1.5);
图例中各个量及位置:legend('y','zc','location','NorthEast');
例:h = legend('C', 'Python');
set(h, 'FontName', 'Times New Roman','FontSize', 22,'FontWeight','normal');
5、 图名的字体及大小设置:
title('title name','FontName','Times New Roman','FontSize',7);
例:title('Real-time Test','FontName','Times New Roman','FontSize',18);
6、显示网格
grid on;
代码及绘图结果:
n = 1 : 1 : 10;
c = [0.084734, 0.085488, 0.088229, 0.083405, 0.086879...
0.091423, 0.081086, 0.079617, 0.084264, 0.083422]
py = [0.36454343795776367, 0.3627622127532959, 0.38152527809143066, 0.3669757843017578, 0.3792576789855957...
0.36858344078063965, 0.3682212829589844, 0.3740968704223633, 0.3665039539337158, 0.36920785903930664]
hold on;
plot(n, c, 'b', 'LineWidth', 2);
plot(n, py, 'r', 'LineWidth', 2);
xlabel('n', 'FontName', 'Times New Roman','FontSize', 22);
ylabel('consume/s', 'FontName', 'Times New Roman', 'FontSize', 22);
axis([0, 11, 0, 0.5]);
set(gca,'FontName', 'Times New Roman', 'FontSize', 18, 'LineWidth', 0.5);
title('Real-time Test', 'FontName', 'Times New Roman', 'FontSize', 18);
h = legend('C', 'Python', 'location', 'NorthEast');
set(h,'FontName', 'Times New Roman','FontSize', 22, 'FontWeight', 'normal');
grid on;