Static Image Export in MATLAB®

How to export plotly graphs as static images in MATLAB®. Plotly supports png, jpg, and more 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, JPEG.


Take a look at the following examples rendered using saveplotlyfig:


PNG Example:

JPEG Example