Show Sidebar Hide Sidebar

Save MATLAB plots as JPG, PDF, PNG | saveas

How to export plotly graphs as static images in MATLAB. Plotly supports png, svg, jpg, and pdf image export.

You can save static images using the following syntax :



>> saveplotlyfig(figure, 'your_image_filename.png')

figure is a struct with data and layout fields.


figure.data is a cell array of structs, containing your trace and data information.


figure.layout is a struct containing your plot's styling information.


Alternatively, you can exclude the layout information and simply provide the data information as follows:

>> saveplotlyfig(data, 'your_image_filename.png')

data is a cell array of structs, containing your trace and data information.


Combine this with a GET request on a plot you (or someone else) has already created :


>> figure = getplotlyfig('demos', 1526)
>> saveplotlyfig(figure, 'your_image_filename.png')

This will save a static image of a plot you've pulled from Plotly's Servers. Plotly supports PNG, PDF, JPEG, SVG.


Take a look at the following examples rendered using saveplotlyfig:


PNG Example:

Example of a MATLAB figure exported to PNG format

PDF Example:
SVG Example:

Example of a MATLAB figure exported to SVG format

JPEG Example

Example of a MATLAB figure exported to JPEG format



Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.