MATLAB graphic format code

Source: Internet
Author: User

I have been learning MATLAB for three years, but I have never been able to see any document about how to do figure formatting in MATLAB. in China ("here we are ") the emphasis on typographical layout is rather low.

With the help of the boss and other people in the office, I finally found a code that can easily generate standard format images using Matlab.

First of all, I think it is ugly to see the following figure (the figure drawn by Matlab by default) in the article. If you don't agree, don't look down. Close the webpage directly ......

 

The beautiful image should be like this:

Second, let's talk about the absolute size of the illustrations in the article:

In general, the width of the Axis chart (for example) should not be half of the width of the line (Text width) on the paper, if it exceeds the limit, it will be ugly. (The image height can be random ). Take the American general letter size paper as an example:

Letter sized paper 8 Gbit/s in (INCHES) and 11 Gbit/s in height. In general, the page margin for the top and bottom of each 1 in, so the image width should not exceed (8 in-2x1 in) when 2 = 3 when in ≈ 3 in.

In addition, the font size of the numbers and coordinate axes in the graph should be 9 points, and the English text size should be 11 pt (the "5th" of Chinese characters is equivalent to 10.5 pt ).

So we have the following Matlab code:

Fig1 = figure; % name the image to be drawn, "fig1". The name is handle)
Xsize = 3; ysize = 2.25; % length and height of the image, 3 inch x 2.25 inch
Xleft = (8-xsize)/2; ytop = (12-ysize)/2;
Set (fig1, 'Units ', 'ences'); % unit: inches
Set (fig1, 'position', [xleft ytop xsize ysize]); % position of the image displayed on the screen
Set (fig1, 'paperunits ', 'inces'); % unit: inches
Set (fig1, 'paperposition', [xleft ytop xsize ysize]); % position of the image displayed on "paper"

Fig1 = plot (X, Y, 'k'); %

Set (GCA, 'fontsize', 9); % The number font size on the coordinate axis is 9 pt
H1 = xlabel ('t (s) '); H2 = ylabel ('U (m)'); % axis name
Set (H1, 'fontsize', 9); % the font size of the X axis is 9 pt
Set (H2, 'fontsize', 9); % the size of the Y axis is 9 pt
Print ('-djpeg', '-r600', 'cutefred ') % output a jpg image named cutefred.jpg at a resolution of 600 dpi
Print ('-depsc','-Tiff ','-r300 ', 'cutefred') % output an EPS image named cutefred. EPS at a resolution of 300 dpi
Print ('-dpdf', 'cutefred ') % output a PDF image named cutefreddy
Print ('-dmeta','-r300 ', 'cutefred') % output an EMF image named cutefred. EMF

% The Four images can be output at the same time and saved in the folder where the code is located.

 

After the image is painted, you can put it in the document without any modification. The chatbot can paste the jpg image into the word (the resolution must be at least 300 dpi ), we recommend that you use EMF to paste the image to the word, geek directly inserts an EPS or PDF image in latex. When you change the image, you only need to adjust the code in MATLAB and press F5. This is too convenient.

*) The PDF image generated using the above Code does not have an automatic edge Cutting (CROP), so if you want to use this PDF file in pdflatex or xelatex, you have to use your own crop (Use Adobe Acrobat or go to http: //Www.javasscissors.com) is actually more troublesome. I do not know the solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.