Save Plot as Image or Vector Graphics File

After you create a plot, you can save it as either a bitmap image or a vector graphics file.

Choose File Format

Before saving the plot, consider whether you want to save the plot as a bitmap image or a vector graphics file.

  • Bitmap images contain a pixel-based representation of the figure. This type of format is widely used by web browsers and other applications that display graphics. However, bitmap images do not scale well. You cannot modify individual graphics objects, such as lines and text, in other graphics applications. Supported bitmap image formats include PNG and JPEG.

  • Vector graphics files store commands that redraw the figure. Use this type of format if you want to edit the figure in another graphics application. Vector graphics files scale well, but can result in a large file. Also, vector graphics files might not produce the correct 3-D arrangement of objects in certain cases. Some applications support extensive editing of vector graphics formats, but some applications support only resizing the graphic. In general, try to make all the necessary changes while your figure is still in MATLAB®. Supported vector graphics formats include PDF, EPS, and SVG.

For a full list of supported file formats, see saveas or print.

Interactively Save Plot

To interactively save a specific plot, use the export button in the toolbar. The button appears when you hover over the axes. When you use the export button, you can save the plot as a PNG, JPEG, TIFF, or PDF file. Other file formats are not supported.

When you use the export button, the saved output is tightly cropped around the axes content, including any legends or colorbars. The output does not include content outside the axes, such as other axes in the figure. If your figure has multiple axes or UI controls and you want to save the contents of the entire figure, then use the File > Save option instead.

Programmatically Save Plot

To programmatically save an entire figure, use the saveas or print function. For example, save a bar chart as a bitmap image file. In this case, use a PNG file format. Then, save a surface chart as a vector graphics file. In this case, use an EPS file format. Use gcf to save the current figure.

bar([1 10 7 8 2 2 9 3 6])


Details of saved and printed figures can differ from the figure on the display. For more control over the saved output, such as setting the resolution or controlling the renderer, use the print function to save the figure.

Open Saved Plot in Other Applications

You can open the saved plot in other applications such as Microsoft® Word or LaTeX.

To add a saved plot to a LaTeX document, first save the plot using an EPS format. For example, saveas(gcf,'BarChart','epsc'). Then, use the \includegraphics element in the LaTeX document to include the file. For example:


\caption{Bar Chart from MATLAB}


See Also

| |

Related Topics