Black Lives Matter. Please consider donating to Black Girls Code today.

Save plots as JPG, PDF, PNG | saveas in MATLAB®

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<sup>®</sup> figure exported to PNG format"></p>

<h6>PDF Example:</h6>

<iframe src=

SVG Example:

Example of a MATLAB<sup>®</sup> figure exported to SVG format"></p>

<h6>JPEG Example</h6>

<p><img src=' + text + ''); } else { return('

  • ' + text + '
  • '); } }).join("")); //$(".tutorial-content :header:not(h6)").append( "\
    ");