When writing academic papers, charts and graphs are important tools for showcasing our research findings. Therefore, creating an exquisite image that ensures content quality can often make our paper more appealing to editors. Currently, images submitted by researchers to publishers can be classified into two types: vector images and pixel images.
First, let’s talk about the differences between vector and pixel images, which are mainly reflected in the following three aspects:
1. Construction Basis
The construction basis of a pixel image is a group of square-shaped pixels, with each pixel storing color information such as RGB values. For a pixel image, if we zoom in to a sufficient degree, we can see these small squares that make up the image.
On the other hand, the construction basis of a vector image is lines and curves (points, lines, polygons, and arcs, etc.) described by mathematical expressions in computer graphics. The colors of the graphics are described by the color of the lines and the color of the filled closed curves.
2. Common File Formats and Editing Software
Currently, common file formats for pixel images include JPG, PNG, BMP, and EPS, with popular editing software such as Adobe Photoshop, Word, and PowerPoint.
Common file formats for vector images include EMF, WMF, EPS, and SVG, with popular editing software such as Adobe Illustrator, Word, PowerPoint, and CorelDRAW. It is important to note that EPS is a proprietary format of the Adobe software series, while EMF and WMF are proprietary file formats of the Office software series.
3. Advantages and Disadvantages Analysis
The clarity of a pixel image depends on the number of pixels, so the higher the resolution of the image, the larger the storage space it occupies. On the other hand, because vector images use formulaic expressions to describe graphics, the size of the image does not depend on pixels or resolution. This also means that vector images often have smaller file sizes than pixel images. However, their disadvantage is that it is difficult to represent complex and realistic image effects with rich color layers or too many color changes. Also, the graphics created by vector images are not as realistic and precise as pixel images, making it difficult to describe various relatively complex shapes (such as real natural landscapes) accurately.
For academic papers, most of the charts and graphs are used to present data, such as line graphs, bar charts, and cloud maps. Therefore, using a highly clear and space-saving vector image is more advantageous than a pixel image.
How to Export High Quality Images from Matlab for Papers?
There are three methods to export vector images from Matlab:
1. Direct output from Matlab
For simple line and curve plots, we can directly export the image from Matlab. We can select File->Export Setup in the graphics window, check the Custom renderer option under the Rendering properties, and change it to ‘painters’ (vector format), as shown in the figure below.
After the change is made, click Export and select the desired vector file format to export the vector image. If further modification is required, it is recommended to export the image in EPS format and edit it using Adobe Illustrator. If editing is required in Word or PowerPoint, save it in EMF format, as shown below.
2.Using exportgraphics function
For Matlab versions 2020a and above, the exportgraphics function can be used to export images to file formats. For example, the following code gives a simple example of exporting an EPS file using the exportgraphics function:
x=linspace(0,1,101);y=sin(x); plot(x,y); exportgraphics(gcf,'imagefile.eps','ContentType','vector')
Here, gcf represents the handle value of the current graphics object (Figure1), and vector represents vector output. For more information on the exportgraphics function, please refer to the help document.
For users who do not have a genuine licensed version of Matlab 2020a or above, they can try using Matlab Online provided by MathWorks.
Matlab Online URL: https://www.mathworks.com/products/matlab-online/matlab-online-versions.html
Just register for a MathWorks account and enjoy 20 hours of free usage time per month, which is sufficient for general plotting needs.
3. Combination of Matlab and Tecplot:
It should be noted that for Matlab versions below 2019, even if the vector file format is specified for functions such as surf that draw 3D surface plots, the resulting image may not be a vector image due to the lack of relevant functions in Matlab. In this case, the combination of Matlab and finite element post-processing software Tecplot can be used to export vector images. Taking the drawing of a surface plot as an example, first, we generate a set of data in Matlab and draw a 3D surface plot:
x=linspace(0,pi,11);y=linspace(0,2*pi,11);[X,Y]=meshgrid(x,y); Z=sin(X).*cos(Y); surf(X,Y,Z);
For Matlab versions below 2019, if the method described earlier is used to export vector images, it can be found that the lines in the resulting image show obvious jaggedness when zoomed in, as shown in the figure below. This indicates that the image is actually a pixel image.
To solve this problem, a method of drawing surface plots using Tecplot is introduced here. The drawing idea is to consider each surface that makes up the surface plot as a quadrilateral finite element mesh and use Tecplot’s function for drawing finite element clouds to draw the surface plot. Therefore, if the variables X and Y are regarded as the grid node coordinates, and the variable Z is regarded as the field variable value at the node, as long as the mesh definition information supported by Tecplot is given, it can be imported into Tecplot to complete the drawing of the surface plot. The construction of the mesh definition information can be implemented based on the function written by the author (see Appendix for the source code of the function), which can be called as follows:
After executing the function, a text file named Mesh_Visual.dat will be generated. Import the file into Tecplot by selecting File->Load Data, switch the drawing mode to 3D Cartesian coordinates, check Mesh and Contour under Show zone layers, and add three-way coordinate axes through Plot->Axis. The surface plot can then be drawn, as shown in the figure below.
Tecplot is the ultimate graphical genie . With its detailed settings, you can easily adjust the coordinate ranges and legend colors to achieve the perfect visual representation of your data. Once you’re happy with the settings, simply select “File” and then “Export” to export your masterpiece as a vector image, just like the one shown in the image below.
The final image:
However, it’s important to note that using Matlab in combination with Tecplot is only suitable for creating simple surface plots or contour plots. For more complex graphs, we recommend using the latest version of Matlab and utilizing the “exportgraphics” function to create stunning visualizations that will captivate your audience.