Skip to content

Repository files navigation

Plotly Graphing Library for MATLAB® and GNU Octave

CI Release

Create interactive, web-based charts in your browser from MATLAB® and GNU Octave.

Version: 3.1.0

MATLAB is a registered trademark of The MathWorks, Inc.

Features

  • Convert native MATLAB and GNU Octave figures to interactive Plotly charts with a single line of code
  • Fully offline: charts render locally in your browser — plotly.js is downloaded once during setup and cached on your machine
  • Publication-quality static export (PNG, JPEG, PDF, SVG) via the Kaleido runtime (downloaded once during setup)
  • Comparison gallery generator (makegallery) showing native and converted figures side by side

Install

Download the latest version of the wrapper:

Then, from the extracted folder, run:

plotlysetup_offline()   % one-time setup: downloads and caches plotly.js for offline usage (requires internet once)

This works in both MATLAB and GNU Octave.

Usage

Convert your MATLAB® or Octave figure into an interactive Plotly chart with a single line of code:

% Create some data for the two curves to be plotted
x  = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);

% Create a plot with 2 y axes using the plotyy function
figure;
[ax, h1, h2] = plotyy(x, y1, x, y2, 'plot');

% Add title and x axis label
xlabel('Time (s)');
title('Frequency Response');

% Use the axis handles to set the labels of the y axes
ylabel(ax(1), 'Low Frequency');
ylabel(ax(2), 'High Frequency');

%--PLOTLY--%
p = fig2plotly; % <-- converts the current figure to an interactive Plotly chart

Sample Plot

The resulting figure is an interactive web chart: pan, zoom, hover, and download from the plotly.js toolbar.

Static export

Export figures to publication-quality static images:

p = fig2plotly;
saveplotlyfig(p, 'testimage.svg')  % PNG, JPEG, PDF, and SVG supported

Online mode

Offline usage is the default and requires nothing. For online features — storing charts on the Plotly cloud, retrieving figures with getplotlyfig, and streaming — configure your Plotly credentials:

plotlysetup_online('your_username', 'your_api_key')

Retrieving figures

Fetch figures stored on the Plotly cloud:

p = getplotlyfig('chris', 1638)  % downloads the graph data

Gallery

Generate a side-by-side comparison of native and converted figures for over 80 plot types:

makegallery('OutputFolder', 'gallery')

Documentation

Questions & troubleshooting

Ask on the Plotly Community Forum.

Contribute

Please do! This is an open source project. Check out the issues or open a PR!

We want to encourage a warm, welcoming, and safe environment for contributing to this project. See the code of conduct for more information.

The test suite (plotly/testing/runplotlytests.m) runs in both MATLAB and GNU Octave and is executed on every push via GitHub Actions.

License

MIT © Plotly, Inc.

Releases

Packages

Used by

Contributors

Languages