Filenames, Folders, and Updating Plotly Graphs in MATLAB®. in MATLAB®

How to update Plotly graphs in MATLAB® with the fileopt parameter.


Specifying filenames, overwriting files, and updating graphs at their unique URLs

By default, Plotly will create a new file when you call fig2plotly. To overwrite a graph, include 'filename', 'my-graph' as the last arguments:

x = linspace(-2pi,2pi);
y1 = sin(x);
y2 = cos(x);

fig = figure; plot(x,y1,x,y2);

response = fig2plotly(fig, 'filename', 'matlab-basic-line'); plotly_url = response.url;


If a graph named "matlab-basic-line" already exists in your account, then it will be overwritten with this new version and the URL of the graph will persist.

Saving to a folder

Filenames that contain "/" be treated as a Plotly directory and will be saved to your Plotly account in a folder tree.

For example, to save your graphs to the folder my-graphs:

fig2plotly(fig, 'filename', 'my-graphs/matlab-basic-line');

If the folder doesn't exist, it will be created.

Creating new files

x = linspace(-2*pi,2*pi);
y1 = sin(x);
y2 = cos(x);

fig = figure;
plot(x,y1,x,y2);

response = fig2plotly(fig);
plotly_url = response.url;


Without specifying a filename, Plotly will always create a new file. If a file with the same name already exists, then Plotly will append a '(1)' to the end of the filename, e.g. basic-line (1) and create a unique URL.