In MATLAB, set the line type, color, and display ratio of the fig picture, and save it as eps, jpg, png and other formats

In MATLAB, sometimes it is necessary to adjust the scale of the picture when drawing a picture.
The following shows some small pieces of MATLAB code, as an example

// 画y = x^2 函数
figure
x = 1:10
plot(x,x.^2,'r-.s','LineWidth',2);

In the above code,
(1) 'r' indicates that the color of the curve is red, and some common color settings: 'b' is blue, 'g' is green, 'k' is black, 'y' is yellow, etc.;
( 2) '-.' indicates that the line type is a dashed line with long and short intervals, and other types, as shown in the figure below:
line type selection

(3) 's' indicates that the legend is a box, and common markers are shown in the figure below:
Marker selection
(4) 'LineWidth' is used to control the line width, and the default value is 1.

The result of running the above code is as follows:
MATLAB Drawing shows y=x^2
Of course, you can also use the drawing tool to modify various parameter settings in the above picture, as shown in the figure below:
Drawing tools to modify parameters such as linearity, color, line width, and legend

Then, the current image parameters can be obtained through the gcf command, as shown in the following figure:
After the gcf command is executed, the image attributes are output
We focus on the four parameters corresponding to the Position line, the first two parameters are the current position coordinates of the image, and the last two are the width and height of the image.
By adjusting the two parameters, you can adjust the proportion of the picture, the specific code is as follows:

// 调整图片的比例
set(gcf, 'Position', [573 437.6667 400 300]);

By adjusting the size of the latter two parameters "400" and "300", you can adjust the display ratio of the picture. The advantage of this command is that for multiple pictures, you can strictly set the display position (the first two parameters) and size (the last two parameters) of the pictures to ensure that the multiple pictures are strictly consistent.
4:3 Photo Exhibition
After we have set the required line type, color, legend and label, as well as the scale and size of the picture, we
can use "File"—> "Save As" to select the appropriate picture saving format according to the needs,
such as in LaTeX, insert Commonly used eps format for pictures, etc.
Save Fig as additional format options

Guess you like

Origin blog.csdn.net/b_b1949/article/details/128323154