Related settings in Matalab drawing

1. Set the upper and lower limits of the coordinate axis:

 axis([xmin,xmax,ymin,ymax]);

 例:axis([0, 11, 0, 0.5]); xmin = 0, xmax = 11, ymin = 0, ymax = 0.5;

2. Related settings of coordinate axis name:

 The name, font and size of the x-axis: xlabel('x(m)','FontName','Times New Roman','FontSize', 7);

 例:xlabel('n','FontName','Times New Roman','FontSize', 22);

3. The font and size setting of the coordinate axis:

 set(gca,'FontName','Times New Roman','FontSize',7,'LineWidth',1.5);

 例:set(gca,'FontName','Times New Roman','FontSize', 18, 'LineWidth',0.5);

4. Related settings of the legend:

 Font and size in the legend: legend('FontName','Times New Roman','FontSize',7,LineWidth',1.5);

 Each amount and location in the legend: legend('y','zc','location','NorthEast');

例:h = legend('C', 'Python');
set(h, 'FontName', 'Times New Roman','FontSize', 22,'FontWeight','normal');

5.  The font and size settings of the image name:

 title('title name','FontName','Times New Roman','FontSize',7);

例:title('Real-time Test','FontName','Times New Roman','FontSize',18);

 6. Display grid

grid on;

 

Code and drawing results:

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;

Guess you like

Origin blog.csdn.net/ting_qifengl/article/details/115001314