Getting Started with Plotly and Chart Studio in MATLAB®

Get started with Plotly's MATLAB® graphing library to make interactive, publication-quality graphs online.


If you have not done so already, download and uncompress the Plotly Graphing Library for MATLAB®.


In your MATLAB® console, begin by locating the downloaded directory, and running plotlysetup_online().

cd ~/Downloads/plotly-graphing-library-for-matlab-master
plotlysetup_online('DemoAccount', 'lr1c37zw81')

You'll need to replace "DemoAccount" and "lr1c37zw81" with your Plotly username and API key.

Find my API key.

You only have to set this up if it's your first time using a Plotly API.

This will set up your credentials and import the Plotly library into your MATLAB® toolboxes. You can now delete the downloaded folder.

Special Instructions for Chart Studio Enterprise Users

Your API key for a Chart Studio Enterprise account will be different from an account on the Plotly cloud. Visit to find your Chart Studio Enterprise API key. Remember to replace "" with the URL of your Chart Studio Enterprise server.

Additionally, you'll have to change the MATLAB® Open Source Graphing Library endpoint so that it points to your company's Plotly server instead of Plotly's cloud. In your MATLAB® console, enter:

saveplotlyconfig('', '')

Alternatively, if you'd like to set your configuration to create private plots by default you should enter:

saveplotlyconfig('', '', 'private')

Make sure to replace "" with the URL of your Chart Studio Enterprise server.Questions? Contact your Plotly representative.

Start Plotting Online!

Now you can convert your MATLAB® figures into beautiful, interactive, online graphs with fig2plotly(gcf);:

[X,Y,Z] = peaks;

fig2plotly(gcf, 'offline', false)

Note: fig2plotly(gcf); will render your plot using Plotly's own color and styling by default. To preserve your original MATLAB® color and styling, use: fig2plotly(gcf,'strip',false).

Learn more about using Plotly Offline for Matlab.


Copy and paste the URL into your browser to see your graph!

url: ''
message: [1x0 char]
warning: [1x0 char]
filename: 'untitled'
error: [1x0 char]


The initialization step places a special .plotly/.credentials file in your home directory. Your ~/.plotly/.credentials file should look something like this:

"username": "DemoAccount",
"stream_ids": ["ylosqsyet5", "h2ct8btk1s", "oxz4fm883b"],
"api_key": "lr1c37zw81"

You can change the contents of this file manually or as described in the Initialization section.