diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e78271e9..c2bc58a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - release: [R2025a, R2026a] + release: [R2021a, R2022a, R2023a, R2024a, R2025a, R2026a] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index d91c6e19..fe885ca1 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -1101,13 +1101,16 @@ function testFunctionContourPlotData(tc) return % The `fcontour` function is not yet implemented in Octave. end fig = figure("Visible","off"); - fcontour(@(x,y) sin(3*x).*cos(x+y),[0 3 0 3],Fill="on",LineColor="k"); + fc = fcontour(@(x,y) sin(3*x).*cos(x+y),[0 3 0 3],Fill="on",LineColor="k"); chartTitle = "f(x,y) = sin(3*x)*cos(x+y)"; title(chartTitle); colormap("spring"); p = plotlyfig(fig,"visible","off"); + % the levels fcontour picks differ between releases + levels = fc.LevelList; + clim = get(fc.Parent, 'CLim'); tc.verifyNumElements(p.data, 1); tc.verifyEqual(rmfield(p.data{1}, ["colorscale" "x" "y" "z"]), struct( ... "xaxis", "x1", ... @@ -1119,14 +1122,14 @@ function testFunctionContourPlotData(tc) "ytype", "array", ... "autocontour", false, ... "contours", struct( ... - "end", 0.8, ... - "start", -1, ... - "size", 0.2, ... + "end", levels(end), ... + "start", levels(1), ... + "size", mean(diff(levels)), ... "coloring", "fill" ... ), ... "zauto", false, ... - "zmin", -1, ... - "zmax", 0.8, ... + "zmin", clim(1), ... + "zmax", clim(2), ... "showscale", false, ... "reversescale", false, ... "line", struct( ... @@ -1610,6 +1613,7 @@ function testVerticalConstantLineWithLabel(tc) )); tc.verifyTrue(any(cellfun(@(ann) contains(ann.text,label), p.layout.annotations))); tc.verifyTrue(any(cellfun(@(ann) ann.xanchor == alignment, p.layout.annotations))); + tc.verifyTrue(any(cellfun(@(ann) strcmp(ann.font.color, 'rgb(255,0,0)'), p.layout.annotations))); try close(); catch; end end @@ -1640,7 +1644,7 @@ function testStackedPlotData(tc) a = cos(x); b = exp(x); dt = datetime(2010,1,1) + years(x); - tb = table(dt',a',b',VariableNames=["date" "a" "b"]); + tb = table(dt',a',b','VariableNames',{'date','a','b'}); stackedplot(tb); p = plotlyfig(fig,"visible","off"); @@ -3040,6 +3044,9 @@ function testPlotTableDataTip(tc) if is_octave() return % DataTipTemplate is not yet implemented in Octave. end + if isMATLABReleaseOlderThan("R2022a") + return % plot(tbl, ...) needs R2022a. + end tb = table(); tb.time = (2:2:12)'; tb.Saved = rand(6,1); diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m index 15af3335..5558d46c 100644 --- a/plotly/plotlyfig_aux/core/updateConstantLine.m +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -59,7 +59,13 @@ annotation.y = get(plotData, 'Value'); end - col = round(255*get(plotData, 'LabelColor')); + % LabelColor only exists since R2024b; its default ('auto' mode) + % is the line color, so older releases fall back to that + if isprop(plotData, 'LabelColor') + col = round(255*get(plotData, 'LabelColor')); + else + col = round(255*get(plotData, 'Color')); + end annotation.font.color = getStringColor(col); annotation.font.family = matlab2plotlyfont(get(plotData, 'FontName')); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index 69e517c6..133bffb7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -77,7 +77,7 @@ col = [255 255 255]; if isfinite(cdata(j,i)) ratio = (cdata(j,i) - data.zmin) / (data.zmax - data.zmin); - colorIndex = 1 + clip(round(ratio*len), 0, len); + colorIndex = 1 + min(max(round(ratio*len), 0), len); c = 255*cmap(colorIndex,:); luminance = [0.299 0.587 0.114] * c'; % ITU-R BT.601 luminance standard if luminance > 128