From 2ebc35b305f37f2c7d1b06835af2858339dee557 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 28 Nov 2026 17:21:30 +0000 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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 = "";