Thanks for helping out! This converter runs in both MATLAB and GNU Octave, so changes should work in both. Below is how to run the tests and how to add support for a new plot type or gallery example.
The test runner is plotly/testing/runplotlytests.m; it discovers every
Test_*.m under plotly/.
addpath(fullfile(pwd, 'plotly', 'testing'));
runplotlytests % everything
runplotlytests('Test_m2json') % one suite
runplotlytests('Test_plotlyfig_lines/testLinePlotData') % one testIn Octave, install the optional packages once if you haven't:
pkg install -forge datatypes statistics.
Every supported graphics type has an updateX function in
plotly/plotlyfig_aux/handlegraphics/. To add one:
-
Inspect the object first. Octave and MATLAB expose different graphics objects. Use
get/setrather than dot indexing. -
Add
plotly/plotlyfig_aux/handlegraphics/updateX.m:function obj = updateX(obj, dataIndex) h = obj.State.Plot(dataIndex).Handle; obj.data{dataIndex}.type = 'scatter'; obj.data{dataIndex}.x = get(h, 'XData'); obj.data{dataIndex}.y = get(h, 'YData'); end
-
Register it in the switch in
plotly/plotlyfig_aux/core/updateData.m. -
Add a test to the matching suite (
Test_plotlyfig_lines,_bars,_3dor_special).
Reusable code belongs in plotly/plotlyfig_aux/helpers/; local functions in
one file are not visible from another.
The gallery compares native and converted figures for each entry in
galleryEntries() at the bottom of plotly/makegallery.m. Add a {name, code}
row:
'myplot', 'myplot(1:10, [3 5 2 8 4 6 9 1 7 5]);'; ...The gallery creates the figure for you, so the code just has to draw into it. Use fixed data (or seed the RNG) so the picture is reproducible, and keep the entry working in both engines when possible. Iterate on a single entry with:
makegallery('Functions', {'myplot'}, 'Open', false)Keep commits to one logical change with a short imperative message.
Releases are made from master by pushing a version tag. CI then tests the
toolbox (.mltbx) and attaches it to a draft GitHub release.
-
Set the new version in
plotly/plotly_aux/plotly_version.m(for example"3.2.0") and merge that change intomaster. This file is the only place the version is kept; the toolbox takes its version from it. -
Tag the merged commit with the plain version (no
vprefix) and push the tag: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 withplotly_matlab-<version>.mltbxattached and release notes generated from the merged pull requests. -
Review the draft on the repository's Releases page and click Publish.
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.