From 2ebc35b305f37f2c7d1b06835af2858339dee557 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 28 Nov 2026 17:21:30 +0000 Subject: [PATCH 01/24] plotly_version: 3.1.0, the latest release --- plotly/plotly_aux/plotly_version.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotly_aux/plotly_version.m b/plotly/plotly_aux/plotly_version.m index f56f5497..fa4ee25f 100644 --- a/plotly/plotly_aux/plotly_version.m +++ b/plotly/plotly_aux/plotly_version.m @@ -1,3 +1,3 @@ function version = plotly_version() - version = "3.0.0"; + version = "3.1.0"; end From 521293f67138f1911763219e3d35eb175993f74f Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 28 Nov 2026 17:22:13 +0000 Subject: [PATCH 02/24] Add buildfile.m with a task that packages the toolbox --- .gitignore | 1 + buildfile.m | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 buildfile.m diff --git a/.gitignore b/.gitignore index a3e48acb..0f98db54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dev/ *.asv untitled.html +release/ diff --git a/buildfile.m b/buildfile.m new file mode 100644 index 00000000..25533a83 --- /dev/null +++ b/buildfile.m @@ -0,0 +1,44 @@ +function plan = buildfile + plan = buildplan(localfunctions); +end + +function packageTask(~) + % Package the plotly folder as a toolbox in release/ + root = fileparts(mfilename('fullpath')); + + % only tracked files: a working copy also holds downloads such as the + % Kaleido binaries under plotly/kaleido + [status, listing] = system(sprintf('git -C "%s" ls-files plotly', root)); + if status ~= 0 + error('buildfile:git', 'git ls-files failed:\n%s', listing); + end + files = string(splitlines(strtrim(listing))); + files = files(~startsWith(files, "plotly/testing/") & ~contains(files, "/Test_")); + folders = unique(regexprep(files(endsWith(files, ".m")), '/[^/]*$', '')); + + version = regexp(fileread(fullfile(root, 'plotly', 'plotly_aux', 'plotly_version.m')), ... + '"(\d+\.\d+\.\d+)"', 'tokens', 'once'); + version = string(version{1}); + + opts = matlab.addons.toolbox.ToolboxOptions(fullfile(root, 'plotly'), ... + "e59f316c-4a80-11e4-9553-005056977bd0"); + opts.ToolboxName = "Plotly Graphing Library for MATLAB"; + opts.ToolboxVersion = version; + opts.Summary = "Convert MATLAB figures into interactive plotly.js charts"; + if isprop(opts, 'Description') % removed in R2026b + opts.Description = "fig2plotly converts MATLAB figures into interactive " + ... + "plotly.js web charts that open in your browser, fully offline. " + ... + "Run getplotlyoffline() once after installing to download plotly.js."; + end + opts.AuthorCompany = "Plotly"; + opts.ToolboxFiles = root + "/" + files; + opts.ToolboxMatlabPath = root + "/" + folders; + opts.MinimumMatlabRelease = "R2021a"; + opts.MaximumMatlabRelease = ""; + opts.OutputFile = fullfile(root, "release", "plotly_matlab-" + version + ".mltbx"); + + if ~isfolder(fullfile(root, "release")) + mkdir(fullfile(root, "release")); + end + matlab.addons.toolbox.packageToolbox(opts); +end From 3169b934fc0d19ca5b2bce74b97856ba8e132c4c Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 28 Nov 2026 17:29:42 +0000 Subject: [PATCH 03/24] addtheme: find the themes next to addtheme.m --- plotly/addtheme.m | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/plotly/addtheme.m b/plotly/addtheme.m index e7aed3b3..3799362a 100644 --- a/plotly/addtheme.m +++ b/plotly/addtheme.m @@ -1,19 +1,8 @@ function f = addtheme(f, theme) %-validate theme name-% - themePath = 'plotly/themes'; - S = dir(themePath); - - if isempty(S) - paths = split(path, ':'); - for p = 1:length(paths) - if ~isempty(strfind(paths{p}, themePath)) - themePath = paths{p}; - break; - end - end - S = dir(themePath); - end + themePath = fullfile(fileparts(mfilename('fullpath')), 'themes'); + S = dir(fullfile(themePath, '*.json')); N = {S.name}; @@ -28,8 +17,7 @@ %-add theme to figure-% - fname = sprintf('%s/%s.json', themePath, theme); - % fname = strcat('plotly/themes/', theme, '.json'); + fname = fullfile(themePath, sprintf('%s.json', theme)); fid = fopen(fname); raw = fread(fid,inf); str = char(raw'); From 5b77ffade24594a99508d4ae7b05ed556d0ff13d Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 28 Nov 2026 17:30:36 +0000 Subject: [PATCH 04/24] CI: package the toolbox and test-install it on R2021a and R2026a --- .github/workflows/ci.yml | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2bc58a5..46319832 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,3 +64,68 @@ jobs: with: name: gallery-${{ matrix.release }} path: gallery/ + + package-toolbox: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + # R2023a is the oldest release with matlab.addons.toolbox.ToolboxOptions + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v3 + with: + release: R2023a + cache: true + + - name: Package toolbox + uses: matlab-actions/run-command@v3 + with: + command: buildtool package + + - name: Upload toolbox + uses: actions/upload-artifact@v4 + with: + name: toolbox + path: release/*.mltbx + + install-toolbox: + name: install-toolbox (${{ matrix.release }}) + needs: package-toolbox + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + release: [R2021a, R2026a] + steps: + # no checkout: fig2plotly must come from the installed toolbox + - name: Download toolbox + uses: actions/download-artifact@v4 + with: + name: toolbox + path: release + + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v3 + with: + release: ${{ matrix.release }} + cache: true + + - name: Install, use and uninstall the toolbox + uses: matlab-actions/run-command@v3 + with: + command: | + mltbx = dir(fullfile("release", "*.mltbx")); + assert(isscalar(mltbx), "expected one .mltbx in release/"); + installed = matlab.addons.toolbox.installToolbox(fullfile(mltbx.folder, mltbx.name)); + disp(installed); + location = which("fig2plotly"); + assert(~isempty(location), "fig2plotly is not on the path after installing"); + disp(location); + fig = figure("Visible", "off"); + plot(1:3); + p = plotlyfig(fig, "visible", "off"); + assert(numel(p.data) == 1, "plotlyfig converted %d traces, expected 1", numel(p.data)); + addtheme(struct("layout", struct()), "ggplot2"); + matlab.addons.toolbox.uninstallToolbox(installed); + assert(isempty(which("fig2plotly")), "fig2plotly is still on the path after uninstalling"); From 81312c69dd16e8c3b40a3f057f73e056ac39cb3a Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 28 Nov 2026 17:32:58 +0000 Subject: [PATCH 05/24] buildfile: ship the LICENSE in the toolbox --- .github/workflows/ci.yml | 1 + buildfile.m | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46319832..63e3d0b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,6 +122,7 @@ jobs: location = which("fig2plotly"); assert(~isempty(location), "fig2plotly is not on the path after installing"); disp(location); + assert(isfile(fullfile(fileparts(location), "LICENSE")), "the toolbox has no LICENSE"); fig = figure("Visible", "off"); plot(1:3); p = plotlyfig(fig, "visible", "off"); diff --git a/buildfile.m b/buildfile.m index 25533a83..6813a167 100644 --- a/buildfile.m +++ b/buildfile.m @@ -20,6 +20,11 @@ function packageTask(~) '"(\d+\.\d+\.\d+)"', 'tokens', 'once'); version = string(version{1}); + % ship the license at the toolbox root; the copy only lives for the build + licenseCopy = fullfile(root, 'plotly', 'LICENSE'); + copyfile(fullfile(root, 'LICENSE'), licenseCopy); + removeLicense = onCleanup(@() delete(licenseCopy)); %#ok + opts = matlab.addons.toolbox.ToolboxOptions(fullfile(root, 'plotly'), ... "e59f316c-4a80-11e4-9553-005056977bd0"); opts.ToolboxName = "Plotly Graphing Library for MATLAB"; @@ -31,7 +36,7 @@ function packageTask(~) "Run getplotlyoffline() once after installing to download plotly.js."; end opts.AuthorCompany = "Plotly"; - opts.ToolboxFiles = root + "/" + files; + opts.ToolboxFiles = [root + "/" + files; string(licenseCopy)]; opts.ToolboxMatlabPath = root + "/" + folders; opts.MinimumMatlabRelease = "R2021a"; opts.MaximumMatlabRelease = ""; From bfd5b58bc4feca8a17d540f10283ed637fd5ecd0 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 07:52:05 +0000 Subject: [PATCH 06/24] CI: test-install the toolbox on R2026b too --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63e3d0b2..256044d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,7 +96,7 @@ jobs: strategy: fail-fast: false matrix: - release: [R2021a, R2026a] + release: [R2021a, R2026a, R2026b] steps: # no checkout: fig2plotly must come from the installed toolbox - name: Download toolbox From 81d521dcfc261afe636acd3d5e77fb1dbde1c0a9 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 07:53:14 +0000 Subject: [PATCH 07/24] CI: run the MATLAB tests on R2026b too --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 256044d4..5b14deaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - release: [R2021a, R2022a, R2023a, R2024a, R2025a, R2026a] + release: [R2021a, R2022a, R2023a, R2024a, R2025a, R2026a, R2026b] steps: - name: Checkout uses: actions/checkout@v4 From 9310178d0bcb105f2bbb9d9a65ce4595bf59802b Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 08:55:41 +0000 Subject: [PATCH 08/24] CI: test-install the toolbox on Windows and macOS (R2026b) --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b14deaf..a44f9c5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,13 +90,19 @@ jobs: path: release/*.mltbx install-toolbox: - name: install-toolbox (${{ matrix.release }}) + name: install-toolbox (${{ matrix.os }}, ${{ matrix.release }}) needs: package-toolbox - runs-on: ubuntu-24.04 + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: + os: [ubuntu-24.04] release: [R2021a, R2026a, R2026b] + include: + - os: windows-latest + release: R2026b + - os: macos-latest + release: R2026b steps: # no checkout: fig2plotly must come from the installed toolbox - name: Download toolbox From 0ae9d9267d6712ed9ad2ed9c070a3c9441e98a4e Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:10:01 +0000 Subject: [PATCH 09/24] CI: destroy the plotlyfig before uninstalling the toolbox --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a44f9c5d..44683f17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,5 +134,7 @@ jobs: p = plotlyfig(fig, "visible", "off"); assert(numel(p.data) == 1, "plotlyfig converted %d traces, expected 1", numel(p.data)); addtheme(struct("layout", struct()), "ggplot2"); + clear p; % plotlyfig's destructor must run while the toolbox is still installed + close(fig); matlab.addons.toolbox.uninstallToolbox(installed); assert(isempty(which("fig2plotly")), "fig2plotly is still on the path after uninstalling"); From 427aa4ae01302fc7931d3bb6e6576b019469bfe0 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:13:14 +0000 Subject: [PATCH 10/24] addtheme: stop printing the theme's background colors --- plotly/addtheme.m | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/plotly/addtheme.m b/plotly/addtheme.m index 3799362a..90eff1fa 100644 --- a/plotly/addtheme.m +++ b/plotly/addtheme.m @@ -25,14 +25,4 @@ theme_template = jsondecode(str); f.layout.template = theme_template; - - if isfield(f.layout.template.layout, 'paper_bgcolor') - disp(strcat('layout.bg_paper:::',... - f.layout.template.layout.paper_bgcolor)) - end - - if isfield(f.layout.template.layout, 'plot_bgcolor') - disp(strcat('layout.plot_bgcolor:::',... - f.layout.template.layout.plot_bgcolor)) - end end From c4ca85a3395cd5d780a46773ae1dcb0000bc7782 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:14:47 +0000 Subject: [PATCH 11/24] CI: update checkout, upload-artifact and download-artifact to their Node 24 releases --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44683f17..01306a14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-26.04 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Install Octave, Xvfb and packages run: | @@ -35,7 +35,7 @@ jobs: release: [R2021a, R2022a, R2023a, R2024a, R2025a, R2026a, R2026b] steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Set up MATLAB uses: matlab-actions/setup-matlab@v3 @@ -60,7 +60,7 @@ jobs: - name: Upload gallery if: ${{ !cancelled() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: gallery-${{ matrix.release }} path: gallery/ @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 # R2023a is the oldest release with matlab.addons.toolbox.ToolboxOptions - name: Set up MATLAB @@ -84,7 +84,7 @@ jobs: command: buildtool package - name: Upload toolbox - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: toolbox path: release/*.mltbx @@ -106,7 +106,7 @@ jobs: steps: # no checkout: fig2plotly must come from the installed toolbox - name: Download toolbox - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: toolbox path: release From e969962c460d662bd59086cbb4bc163270f0fcd0 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:24:11 +0000 Subject: [PATCH 12/24] README: drop the Version line; plotly_version.m holds the version --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e6782e61..0ecfabde 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ -Version: 3.1.0 - *MATLAB is a registered trademark of The MathWorks, Inc.* ## Features From 06231f3d821e1370a0209aaa95911d431d29f961 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:24:36 +0000 Subject: [PATCH 13/24] CI: on a version tag, attach the tested toolbox to a draft release --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01306a14..6ea7beeb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: push: branches: [master, develop] + tags: ['[0-9]+.[0-9]+.[0-9]+'] pull_request: jobs: @@ -71,6 +72,17 @@ jobs: - name: Checkout uses: actions/checkout@v7 + # the toolbox version comes from plotly_version.m, and File Exchange + # expects it to equal the release version + - name: Check the tag matches plotly_version.m + if: startsWith(github.ref, 'refs/tags/') + run: | + version=$(grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' plotly/plotly_aux/plotly_version.m | tr -d '"') + if [ "$version" != "$GITHUB_REF_NAME" ]; then + echo "::error::tag $GITHUB_REF_NAME does not match plotly_version.m ($version)" + exit 1 + fi + # R2023a is the oldest release with matlab.addons.toolbox.ToolboxOptions - name: Set up MATLAB uses: matlab-actions/setup-matlab@v3 @@ -138,3 +150,27 @@ jobs: close(fig); matlab.addons.toolbox.uninstallToolbox(installed); assert(isempty(which("fig2plotly")), "fig2plotly is still on the path after uninstalling"); + + # A draft is published by hand: File Exchange and Zenodo pick up the release + # when it is published, and by then the .mltbx is already attached. + release: + if: startsWith(github.ref, 'refs/tags/') + needs: [octave-tests, matlab-tests, install-toolbox] + runs-on: ubuntu-24.04 + permissions: + contents: write + steps: + # the exact .mltbx the install jobs tested + - name: Download toolbox + uses: actions/download-artifact@v8 + with: + name: toolbox + path: release + + - name: Create draft release + env: + GH_TOKEN: ${{ github.token }} + run: >- + gh release create "$GITHUB_REF_NAME" release/*.mltbx + --repo "$GITHUB_REPOSITORY" --verify-tag --draft + --title "$GITHUB_REF_NAME" --generate-notes From c8832fd1ea3568179e28b26eb4388dcd55dfab55 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:29:59 +0000 Subject: [PATCH 14/24] CONTRIBUTING: describe how to make a release --- CONTRIBUTING.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c2cc8b48..7ac57197 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,3 +62,32 @@ makegallery('Functions', {'myplot'}, 'Open', false) ``` Keep commits to one logical change with a short imperative message. + +## Releasing + +Releases are made from `master` by pushing a version tag. CI then tests the +toolbox (`.mltbx`) and attaches it to a draft GitHub release. + +1. Set the new version in `plotly/plotly_aux/plotly_version.m` (for example + `"3.2.0"`) and merge that change into `master`. This file is the only place + the version is kept; the toolbox takes its version from it. +2. Tag the merged commit with the plain version (no `v` prefix) and push the + tag: + + ```bash + git tag 3.2.0 + git push origin 3.2.0 + ``` + + CI checks that the tag matches `plotly_version.m`, runs all the tests, + installs the packaged toolbox on Linux, Windows and macOS, and then creates + a draft release with `plotly_matlab-.mltbx` attached and release + notes generated from the merged pull requests. +3. Review the draft on the repository's Releases page and click **Publish**. + Services connected to the repository, such as File Exchange and Zenodo, are + notified when the release is published, which is why CI only creates a + draft: by then the `.mltbx` is already attached. + +If CI fails, nothing has been published yet. Delete the draft if there is one, +delete the tag (`git push --delete origin 3.2.0` and `git tag -d 3.2.0`), fix +the problem, and tag again. From 0dc7da0d9eee121518948f3f1f0cf646f00a19a6 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:46:46 +0000 Subject: [PATCH 15/24] getplotlyoffline: default to the pinned plotly.js bundle --- plotly/plotly_offline_aux/getplotlyoffline.m | 6 ++++++ plotlysetup_offline.m | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plotly/plotly_offline_aux/getplotlyoffline.m b/plotly/plotly_offline_aux/getplotlyoffline.m index e4ac2816..327066cc 100644 --- a/plotly/plotly_offline_aux/getplotlyoffline.m +++ b/plotly/plotly_offline_aux/getplotlyoffline.m @@ -1,4 +1,10 @@ function getplotlyoffline(plotly_bundle_url) + % GETPLOTLYOFFLINE(url) downloads the plotly.js bundle used for offline + % plots; without url it downloads plotly.js 2.35.3 + if nargin < 1 + plotly_bundle_url = 'https://cdn.plot.ly/plotly-2.35.3.min.js'; + end + try % download bundle plotly_bundle = webread(plotly_bundle_url); diff --git a/plotlysetup_offline.m b/plotlysetup_offline.m index 2ef9d18f..085311a9 100644 --- a/plotlysetup_offline.m +++ b/plotlysetup_offline.m @@ -1,7 +1,7 @@ function plotlysetup_offline(plotly_bundle_url, varargin) % CALL: plotlysetup_offline(plotly_bundle_url); % WHERE: plotly_bundle_url is the plotly bundle url, e.g. https://cdn.plot.ly/plotly-2.35.3.min.js - % If no argument is provided, the default https://cdn.plot.ly/plotly-2.35.3.min.js is used. + % If no argument is provided, getplotlyoffline's default bundle is used. % [1] adds plotly api to search path and prints how to keep it there %DEFAULT OUTPUT @@ -9,9 +9,7 @@ function plotlysetup_offline(plotly_bundle_url, varargin) exception.identifier = ''; try %check number of inputs - if nargin == 0 - plotly_bundle_url = 'https://cdn.plot.ly/plotly-2.35.3.min.js'; - elseif nargin>1 + if nargin>1 error('plotly:wrongInput',.... ['\n\nWhoops! Wrong number of inputs. Please run >> help plotlysetup_offline \n',... 'for more information regarding the setup your Plotly API MATLAB \n',... @@ -43,7 +41,11 @@ function plotlysetup_offline(plotly_bundle_url, varargin) %get offline bundle fprintf('\nNow downloading the plotly offline bundle ...'); - getplotlyoffline(plotly_bundle_url); + if nargin == 0 + getplotlyoffline(); + else + getplotlyoffline(plotly_bundle_url); + end %greet the people! fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n') From 609b9b05b3dc935cf833f9d69dbefc5dbe4ac371 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:50:52 +0000 Subject: [PATCH 16/24] getplotlyoffline: download with urlread in Octave, whose webread fails --- plotly/Test_plotlysetup.m | 17 +++++++++++++++++ plotly/plotly_offline_aux/getplotlyoffline.m | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/plotly/Test_plotlysetup.m b/plotly/Test_plotlysetup.m index 434efa49..2c4929dc 100644 --- a/plotly/Test_plotlysetup.m +++ b/plotly/Test_plotlysetup.m @@ -35,6 +35,23 @@ function testPrintPlotlyPathHint(tc) tc.verifyTrue(~isempty(strfind(output, ... 'addpath(genpath(''/opt/it''''s here/plotly''));')), output); end + + function testGetPlotlyOfflineDownloadsBundle(tc) + if isempty(getenv('CI')) + return % downloads plotly.js from the CDN + end + sandbox = Test_plotlysetup.enterSetupSandbox(); %#ok + if ~strcmp(getuserdir(), getenv('HOME')) + return % getuserdir() is outside the sandbox, so this would replace the real bundle. + end + + evalc('getplotlyoffline()'); + + bundle = fileread(fullfile(getenv('HOME'), '.plotly', 'plotlyjs', ... + 'plotly-matlab-offline-bundle.js')); + tc.verifyTrue(~isempty(strfind(bundle(1:min(end, 100)), 'plotly.js v2.35.3')), ... + 'the saved bundle does not start with the plotly.js 2.35.3 header'); + end end methods (Static) diff --git a/plotly/plotly_offline_aux/getplotlyoffline.m b/plotly/plotly_offline_aux/getplotlyoffline.m index 327066cc..19985b39 100644 --- a/plotly/plotly_offline_aux/getplotlyoffline.m +++ b/plotly/plotly_offline_aux/getplotlyoffline.m @@ -6,8 +6,12 @@ function getplotlyoffline(plotly_bundle_url) end try - % download bundle - plotly_bundle = webread(plotly_bundle_url); + % download bundle; Octave 11.1's webread errors even on plain web pages + if is_octave() + plotly_bundle = urlread(plotly_bundle_url); + else + plotly_bundle = webread(plotly_bundle_url); + end catch exception disp("Whoops! There was an error attempting to download the MATLAB offline Plotly bundle"); rethrow(exception); From a44d4639ffd875d8058f90dced949cdd9b89ebba Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 09:59:42 +0000 Subject: [PATCH 17/24] README: install the toolbox, or from source in Octave; add uninstall steps --- README.md | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0ecfabde..1821feef 100644 --- a/README.md +++ b/README.md @@ -16,23 +16,44 @@ ## Features - Convert native MATLAB and GNU Octave figures to interactive [Plotly](https://plotly.com) 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 +- Fully offline: charts render locally in your browser — plotly.js is downloaded once after installing 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: +### MATLAB (R2021a or later) -- [github.com/plotly/plotly_matlab/archive/master.zip](https://github.com/plotly/plotly_matlab/archive/master.zip) +1. Download `plotly_matlab-.mltbx` from the [latest release](https://github.com/plotly/plotly_matlab/releases/latest). +2. In MATLAB's file browser, double-click the file and follow the installer, or run: -Then, from the extracted folder, run: + ```matlab + matlab.addons.install('plotly_matlab-.mltbx') + ``` + + The toolbox installs into your Add-Ons folder, and MATLAB adds it to the path. +3. Download plotly.js (needs an internet connection the first time): + + ```matlab + getplotlyoffline() + ``` + +### GNU Octave, or MATLAB from source + +Download the [source](https://github.com/plotly/plotly_matlab/archive/master.zip) (or clone the repository), then run from the extracted folder: ```matlab -plotlysetup_offline() % one-time setup: downloads and caches plotly.js for offline usage (requires internet once) +plotlysetup_offline() % adds plotly to the path and downloads plotly.js (requires internet once) ``` -This works in both MATLAB and GNU Octave. +This adds plotly to the path for the current session and prints the `addpath` line to add to your `~/.octaverc` (Octave) or `startup.m` (MATLAB) to keep it there. + +### Uninstall + +- Toolbox: `matlab.addons.uninstall('Plotly Graphing Library for MATLAB')` +- Source: delete the folder and the `addpath` line from your `~/.octaverc` or `startup.m` + +The plotly.js bundle and any saved Plotly credentials are kept in a `.plotly` folder in your home folder (`%APPDATA%\.plotly` on Windows); delete it to remove them too. ## Usage @@ -78,7 +99,7 @@ saveplotlyfig(p, 'testimage.svg') % PNG, JPEG, PDF, and SVG supported 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: ```matlab -plotlysetup_online('your_username', 'your_api_key') +saveplotlycredentials('your_username', 'your_api_key') ``` ## Retrieving figures From 0f203161819fc9ecec1254f04ca1d03b656b2b60 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 10:08:05 +0000 Subject: [PATCH 18/24] Explain the draft release more plainly --- .github/workflows/ci.yml | 4 ++-- CONTRIBUTING.md | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ea7beeb..a57858c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -151,8 +151,8 @@ jobs: matlab.addons.toolbox.uninstallToolbox(installed); assert(isempty(which("fig2plotly")), "fig2plotly is still on the path after uninstalling"); - # A draft is published by hand: File Exchange and Zenodo pick up the release - # when it is published, and by then the .mltbx is already attached. + # Creates a draft with the .mltbx attached; a maintainer publishes it, so + # services that react to published releases see it complete. release: if: startsWith(github.ref, 'refs/tags/') needs: [octave-tests, matlab-tests, install-toolbox] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7ac57197..73e3d9ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,9 +84,6 @@ toolbox (`.mltbx`) and attaches it to a draft GitHub release. a draft release with `plotly_matlab-.mltbx` attached and release notes generated from the merged pull requests. 3. Review the draft on the repository's Releases page and click **Publish**. - Services connected to the repository, such as File Exchange and Zenodo, are - notified when the release is published, which is why CI only creates a - draft: by then the `.mltbx` is already attached. If CI fails, nothing has been published yet. Delete the draft if there is one, delete the tag (`git push --delete origin 3.2.0` and `git tag -d 3.2.0`), fix From 271198e5b9e29527f471c51b68cbe9b38829282b Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 10:20:34 +0000 Subject: [PATCH 19/24] getplotlyoffline: point to saveplotlycredentials, which the toolbox includes --- plotly/plotly_offline_aux/getplotlyoffline.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotly_offline_aux/getplotlyoffline.m b/plotly/plotly_offline_aux/getplotlyoffline.m index 19985b39..800d2e67 100644 --- a/plotly/plotly_offline_aux/getplotlyoffline.m +++ b/plotly/plotly_offline_aux/getplotlyoffline.m @@ -39,7 +39,7 @@ function getplotlyoffline(plotly_bundle_url) % success! fprintf(['\nSuccess! You can now generate offline ', ... 'graphs.\nTo generate online graphs, run ', ... - 'plotlysetup_online(username, api_key) ', ... + 'saveplotlycredentials(username, api_key) ', ... '\nand use the ''offline'' flag of fig2plotly as ', ... 'follows:\n\n>> plot(1:10); fig2plotly(gcf, ', ... '''offline'', false);\n\n']) From 9430803e93232ab4e771b56eac4e646b696c3e75 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 10:22:27 +0000 Subject: [PATCH 20/24] buildfile: read git ls-files -z so unusual file names keep their paths --- buildfile.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/buildfile.m b/buildfile.m index 6813a167..39dc9b11 100644 --- a/buildfile.m +++ b/buildfile.m @@ -7,12 +7,19 @@ function packageTask(~) root = fileparts(mfilename('fullpath')); % only tracked files: a working copy also holds downloads such as the - % Kaleido binaries under plotly/kaleido - [status, listing] = system(sprintf('git -C "%s" ls-files plotly', root)); + % Kaleido binaries under plotly/kaleido; -z lists names unquoted, + % separated by NUL characters + [status, listing] = system(sprintf('git -C "%s" ls-files -z plotly', root)); if status ~= 0 error('buildfile:git', 'git ls-files failed:\n%s', listing); end - files = string(splitlines(strtrim(listing))); + files = split(string(listing), char(0)); + files = files(files ~= ""); + missing = files(~isfile(root + "/" + files)); + if ~isempty(missing) + error('buildfile:missingFiles', 'git ls-files listed files that do not exist:\n%s', ... + strjoin(missing, newline)); + end files = files(~startsWith(files, "plotly/testing/") & ~contains(files, "/Test_")); folders = unique(regexprep(files(endsWith(files, ".m")), '/[^/]*$', '')); From 5537c36ac7e043dcbf49a446ffac42a65364b88a Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 10:24:11 +0000 Subject: [PATCH 21/24] buildfile: print how many files go into the toolbox --- buildfile.m | 1 + 1 file changed, 1 insertion(+) diff --git a/buildfile.m b/buildfile.m index 39dc9b11..1fa2af60 100644 --- a/buildfile.m +++ b/buildfile.m @@ -52,5 +52,6 @@ function packageTask(~) if ~isfolder(fullfile(root, "release")) mkdir(fullfile(root, "release")); end + fprintf('Packaging %d files into %s\n', numel(opts.ToolboxFiles), opts.OutputFile); matlab.addons.toolbox.packageToolbox(opts); end From b61cc858f747589215c51cdd70c7545a0b91cd33 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 10:25:36 +0000 Subject: [PATCH 22/24] buildfile: say which file to fix when no version can be read --- buildfile.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildfile.m b/buildfile.m index 1fa2af60..d02e3b58 100644 --- a/buildfile.m +++ b/buildfile.m @@ -25,6 +25,10 @@ function packageTask(~) version = regexp(fileread(fullfile(root, 'plotly', 'plotly_aux', 'plotly_version.m')), ... '"(\d+\.\d+\.\d+)"', 'tokens', 'once'); + if isempty(version) + error('buildfile:version', ... + 'could not read a version like "1.2.3" from plotly/plotly_aux/plotly_version.m'); + end version = string(version{1}); % ship the license at the toolbox root; the copy only lives for the build From 19336fc8d0d008289e3c80ecdc226d2dde60e549 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 10:28:17 +0000 Subject: [PATCH 23/24] addtheme: report an unknown theme with error(), listing the valid names --- plotly/addtheme.m | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plotly/addtheme.m b/plotly/addtheme.m index 90eff1fa..2e9f4f47 100644 --- a/plotly/addtheme.m +++ b/plotly/addtheme.m @@ -6,13 +6,10 @@ N = {S.name}; - if ~any(strcmp(N,strcat(theme, '.json'))) == 1 - ME = MException('MyComponent:noSuchVariable', ... - [strcat('\n', theme, ... - ' is not a supported themes.'), ... - ' Please choose one of these theme names:\n\n', ... - strrep(strrep([S.name], '...', ''), '.json', ' | ')]); - throw(ME) + if ~any(strcmp(N, strcat(theme, '.json'))) + error('addtheme:unknownTheme', ... + '%s is not a supported theme. Choose one of: %s', ... + theme, strjoin(strrep(N, '.json', ''), ' | ')); end %-add theme to figure-% From f0a6242eaa3f09b73e464c740ee5e7ead3d345c5 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 30 Nov 2026 10:33:39 +0000 Subject: [PATCH 24/24] buildfile: list files with core.quotePath=false; MATLAB's system mangles git ls-files -z --- buildfile.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/buildfile.m b/buildfile.m index d02e3b58..114a0a6e 100644 --- a/buildfile.m +++ b/buildfile.m @@ -7,14 +7,13 @@ function packageTask(~) root = fileparts(mfilename('fullpath')); % only tracked files: a working copy also holds downloads such as the - % Kaleido binaries under plotly/kaleido; -z lists names unquoted, - % separated by NUL characters - [status, listing] = system(sprintf('git -C "%s" ls-files -z plotly', root)); + % Kaleido binaries under plotly/kaleido; core.quotePath=false keeps + % names with non-ASCII characters unquoted + [status, listing] = system(sprintf('git -C "%s" -c core.quotePath=false ls-files plotly', root)); if status ~= 0 error('buildfile:git', 'git ls-files failed:\n%s', listing); end - files = split(string(listing), char(0)); - files = files(files ~= ""); + files = string(splitlines(strtrim(listing))); missing = files(~isfile(root + "/" + files)); if ~isempty(missing) error('buildfile:missingFiles', 'git ls-files listed files that do not exist:\n%s', ...