Printing and Exporting Figures with MATLAB | ![]() ![]() |
MATLAB file formats come in both bitmap and vector varieties. The first column in Table 4-1, Export Formats and Export-Only Options, indicates whether a format is bitmap or vector.
Bitmap formats store graphics as matrices of pixels. Vector formats use drawing commands to store graphics as geometric objects. Vector commands are interpreted by the final output device (e.g., a printer) and result in high quality lines and text.
Whether to use a bitmap or vector format depends mostly on the type of objects in your figure. The following table summarizes when to use a bitmap or vector format. An explanation follows.
Figure Characteristics |
Best Format |
High complexity 3-D |
Bitmap |
Lighting |
Bitmap |
Line plots |
Vector |
Low complexity 2-D |
Vector |
Shading (interpolated) |
Bitmap |
Transparency |
Bitmap (OpenGL renderer only) |
Impact of Rendering Method on Output
If you use a bitmap format, no matter what rendering setting you use, the exported file will contain a bitmap. If you have the renderer set to Painter's, it will be ignored.
Vector format files, however, can store your figure as a vector or bitmap graphic depending on the renderer used to export it. If you do not specify a rendering method and MATLAB chooses the OpenGL or Z-buffer renderer, your exported vector file will contain a bitmap. If you want your figure exported as a vector graphic, be sure to set the rendering method to Painter's. See Reasons for Changing the Renderer for more information.
Figures Most Appropriate for Bitmap Formats
Bitmaps are preferable for high-complexity plots, where complexity is determined by the number of polygons, the number of polygons with interpolated shading, the number of markers, the presence of truecolor images, and other factors. An example of a high-complexity plot is a surface plot that uses interpolated shading.
Benefits and Drawbacks of Bitmap Formats. Bitmap files result in smaller files than vector files for complex plots. However, resizing bitmap formats within another application can degrade their quality. For more information, see Getting the Best Results With Bitmap Formats.
Lighting and Transparency Support. Surface lighting and transparency are only supported by bitmap graphics formats. If you use a vector format, the lighting and transparency disappear. Note that of the two renderers intended for bitmaps (OpenGL and Z-buffer) only OpenGL supports transparency.
Figures Most Appropriate for Vector Formats
Vector formats are preferable for most 2-D plots and for some low complexity surface plots.
Benefits and Drawbacks of Vector Formats. Generally, vector formats create better lines and text than bitmap formats. Another benefit to using vector files is that you can resize them without losing quality. (However, not all applications that support vector formats enable you to resize them.)
If you use a vector format with the Painter's renderer (which is the most appropriate renderer to use), lighting and transparency are not supported. They will be missing from the output figure. The figure retains all the appropriate data. If you set the renderer back to OpenGL or Z-buffer, the missing objects reappear.
Caution If you export to an EPS file using the Painter's renderer and include a TIFF preview, the preview image is a bitmap and will therefore show lighting or transparency when displayed on your screen. Remember that the underlying format vector file, which is what normally gets printed, does not support these features. For more information about EPS files, see EPS Files. |
Size of Output Files from Bitmap or Vector Formats
In general, bitmap formats produce smaller files for complex plots than vector formats, and vector formats produce smaller files for simple plots than bitmap formats.
Bitmap Output Size. The complexity of a figure has no effect on the file size of a bitmap-format file, if the format doesn't use compression. Most of the MATLAB export formats do not support compression. You can calculate the size of your exported figure by multiplying the figure size by its resolution and the bit depth of the chosen format. For example, if a figure is 2 inches by 3 inches and has a resolution of 100 dpi (dots per inch), it will consist of , or 60,000 pixels. If exported to an 8-bit file, it uses 480,000 bits, or 60KB. If exported to a 24-bit file, it uses three times the number of bytes, or 180KB. Because of these issues, you may have to make trade-offs between size, resolution, and bit depth to accommodate your memory resources.
The file size of compressed bitmap files, such as those formatted using the RLE-compressed TIFF format (-dtiff
), is sometimes related to the complexity of the figure. RLE compression, in particular, takes advantage of large areas that use a single color, such as a solid background. Therefore, the more single-color areas a figure has, the smaller the compressed file will be.
Vector Output Size. Vector format file size is affected by the complexity and number of objects in your figure. As the complexity and number of objects increase, the number of drawing commands increases.
The resolution setting and size of your figure have little effect on file size, and most vector files have no associated bit depth. Therefore you can not use the bitmap-size formula shown above to calculate the filesize of a vector file.
Complex plots, such as those using interpolated shading or texture mapping are large and inefficient when stored as a vector graphic. In addition, once imported to another software application, they can be difficult to print due to their size.
Note Note that "vector file" in this context refers to a file that contains no images and was rendered with the Painter's algorithm. Some vector files contain images and therefore have an associated bit depth that affects the file size. See Bit Depths and Vector Formats. |
A Comparison of a Bitmap and a Vector Format
The figures below compare the results of exporting MATLAB figures to both a bitmap format (TIFF) and a vector format (EPS). The comparisons help to enforce some of the concepts discussed in this section. Note that the TIFF files (bitmap) were exported using a high resolution setting of 300 dpi.
The figure below shows a bitmap and a vector of a figure containing long, thin lines. The lines in the bitmap are not quite as crisp as in the vector, but otherwise the quality is comparable.
Figure 4-2: Figure Containing Lines Exported to Bitmap and Vector Files
The next figure contains shorter line segments, and the quality between the two formats is nearly indistinguishable.
Figure 4-3: Figure With Shorter Line Segments Exported to Bitmap and Vector Files
In a surface with interpolated shading the quality is comparable, but in the vector file, the lighting has disappeared because vector files do not support lighting. Note also how the vector file does not accurately portray the shading in the inner cone.
Figure 4-4: Surface with Lighting Exported to Bitmap and Vector Files
![]() | More About MATLAB Format Types | Preserving Colors in Exported Figures | ![]() |