Common Skills of Matlab Drawing in Papers

For the drawing in the paper, it is often required that Chinese should be in Song style, and English and numbers should be in New Roman font. The commonly used formatting functions are as follows:

%设置图像中全部的格式为新罗马字体,这里是为了设置坐标轴中的数字格式,论文中的小五我一般是使用10~10.5大小的字号来显示
set(gca,'FontSize',10,'Fontname', 'Times New Roman');

%设置X,Y轴标签,这里使用   \fontname{
    
    字体}\fontsize{
    
    字号}文字   语句来分别设置同一个标签中不同字体的格式,这个语法比较通用
xlabel('\fontname{宋体}\fontsize{10}时间\fontname{Times New Roman}\fontsize{10}(s)')
ylabel('\fontname{宋体}\fontsize{10}位移\fontname{Times New Roman}\fontsize{10}(mm)')

%设置X,Y轴的显示范围
xlim([-80 80])
ylim([-80 80])

In addition, there are some commonly used drawing functions, as follows
1. Make the ratio of the X and Y axis coordinate axes the same, which is often used to display images such as circles

axis equal

2. Add annotations to the curves drawn successively

legend('\fontname{宋体}\fontsize{10}曲线一','\fontname{宋体}\fontsize{10}曲线二');

3. Different vertical coordinates are displayed on the left and right sides of the same picture

yyaxis left
plot(d2,'b','Linewidth',1.2);
set(gca,'FontSize',10,'Fontname', 'Times New Roman');
xlabel('\fontname{宋体}\fontsize{10}序号')
ylabel('\fontname{宋体}\fontsize{10}纵轴一')

yyaxis right
plot(d2,'--r','Linewidth',1.2);
ylabel('\fontname{宋体}\fontsize{10}纵轴二')

One thing to note here is that the colors of the drawn coordinate axes are inconsistent. You can use the following steps to
first open the drawing tool

and click one of the vertical axes, and the following interface will appear. Change its color to black
insert image description here
and then click another vertical axis, and it will also appear. This modification interface, here you need to pay attention, if you change it directly to black, it may not work, you can change it to other colors first, and then change it to black, that's it.

4. There are two ways to draw a histogram
4.1 The number of each number in the statistical data to draw a histogram

hist(d);

4.2 Draw a histogram based on the values ​​in the data

bar(size(d,1),d);

5. Regarding the opening of the drawing window
5.1 There is no box in the upper right corner, add hold on before plotting
insert image description here
5.2 There is a box in the upper right corner, do not add hold on before the plotting function plot, if necessary, you can add it after
insert image description here

Guess you like

Origin blog.csdn.net/qq_41372644/article/details/125384658