From 1b5bb4061cdcfe229feab249d5b40f4f2e6f6a0f Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 21 Nov 2026 12:22:33 +0000 Subject: [PATCH 1/6] skip the axis update for scatterhistogram charts --- plotly/plotlyfig_aux/helpers/specialAxisPlots.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotlyfig_aux/helpers/specialAxisPlots.m b/plotly/plotlyfig_aux/helpers/specialAxisPlots.m index 389205bf..14c7a7ac 100644 --- a/plotly/plotlyfig_aux/helpers/specialAxisPlots.m +++ b/plotly/plotlyfig_aux/helpers/specialAxisPlots.m @@ -1,3 +1,3 @@ function out = specialAxisPlots() - out = {'polaraxes' 'stackedplot' 'uicontextmenu' 'legend'}; + out = {'polaraxes' 'stackedplot' 'scatterhistogram' 'uicontextmenu' 'legend'}; end From a96fefb54d829fd6fd0011fe312bd2d557936ec1 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 21 Nov 2026 12:23:35 +0000 Subject: [PATCH 2/6] updateScatterhistogram: set nbinsy on the Y marginal histogram --- .../plotlyfig_aux/handlegraphics/updateScatterhistogram.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index 62547144..deaad6b6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -186,14 +186,14 @@ function updateMarginalHistogram(obj, plotIndex, axName) obj.data{traceIndex}.histfunc = 'count'; obj.data{traceIndex}.showlegend = false; + tmpNumBins = get(plotData, 'NumBins'); switch axName case 'X' - tmpNumBins = get(plotData, 'NumBins'); obj.data{traceIndex}.orientation = 'v'; - try obj.data{traceIndex}.nbinsx = tmpNumBins(1,t); end + obj.data{traceIndex}.nbinsx = tmpNumBins(1,t); case 'Y' obj.data{traceIndex}.orientation = 'h'; - try obj.data{traceIndex}.nbinsy = tmpNumBins(2,t); end + obj.data{traceIndex}.nbinsy = tmpNumBins(2,t); end %-link legend-% From ef15b1a151b795c60222b74f1bda46f8d2da2275 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 21 Nov 2026 12:23:35 +0000 Subject: [PATCH 3/6] updateScatterhistogram: scale marginal colors to 0-255 --- plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index deaad6b6..c420e939 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -179,7 +179,7 @@ function updateMarginalHistogram(obj, plotIndex, axName) %-set other trace properties-% tmpColor = get(plotData, 'Color'); - traceColor = getStringColor(tmpColor(t,:), 0.7); + traceColor = getStringColor(round(255*tmpColor(t,:)), 0.7); obj.data{traceIndex}.marker.color = traceColor; obj.data{traceIndex}.histnorm = 'probability'; @@ -247,7 +247,7 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.y = ySmooth; %-set other trace properties-% - traceColor = getStringColor(tmpColor(t,:), 0.7); + traceColor = getStringColor(round(255*tmpColor(t,:)), 0.7); tmpLineStyle = get(plotData, 'LineStyle'); lineStyle = tmpLineStyle(t); From 1c4d396a4598716c28fa120b2f9ac107641b1422 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 21 Nov 2026 12:23:42 +0000 Subject: [PATCH 4/6] updateScatterhistogram: read Color for smooth marginals --- plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m | 1 + 1 file changed, 1 insertion(+) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index c420e939..36fd3fc7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -247,6 +247,7 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.y = ySmooth; %-set other trace properties-% + tmpColor = get(plotData, 'Color'); traceColor = getStringColor(round(255*tmpColor(t,:)), 0.7); tmpLineStyle = get(plotData, 'LineStyle'); lineStyle = tmpLineStyle(t); From 5f556ed4d3e5cc1752b33054828be96a2c96b226 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 21 Nov 2026 12:24:09 +0000 Subject: [PATCH 5/6] Test_plotlyfig: add testScatterHistogramData --- plotly/Test_plotlyfig.m | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index c8c550e9..11f487b7 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -2057,6 +2057,67 @@ function testIsosurfacePlotData(tc) try close(); catch; end end + function testScatterHistogramData(tc) + if is_octave() + return % The `scatterhistogram` function is not yet implemented in Octave. + end + fig = figure("Visible","off"); + x = [0.15 0.19 0.04 0.64 0.28 0.54 0.70 0.50 0.54 0.45]; + y = [0.12 0.49 0.85 0.87 0.27 0.21 0.56 0.64 0.42 0.21]; + s = scatterhistogram(x, y, "Color", [0.5 0.25 0], "MarkerStyle", "o"); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 3); + tc.verifyEqualStructs(p.data{1}, struct( ... + "type", "scatter", ... + "mode", "markers", ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "visible", true, ... + "name", '', ... + "x", s.XData, ... + "y", s.YData, ... + "marker", struct( ... + "size", PlotlyTestCase.AnyNumber(true), ... + "symbol", "circle", ... + "line", struct( ... + "width", s.LineWidth, ... + "color", "rgb(128,64,0)" ... + ), ... + "color", "rgb(128,64,0)" ... + ), ... + "showlegend", false ... + )); + tc.verifyEqualStructs(p.data{2}, struct( ... + "type", "histogram", ... + "xaxis", "x2", ... + "yaxis", "y2", ... + "x", s.XData, ... + "y", s.YData, ... + "marker", struct("color", "rgba(128,64,0,0.700000)"), ... + "histnorm", "probability", ... + "histfunc", "count", ... + "showlegend", false, ... + "orientation", "v", ... + "nbinsx", s.NumBins(1) ... + )); + tc.verifyEqualStructs(p.data{3}, struct( ... + "type", "histogram", ... + "xaxis", "x3", ... + "yaxis", "y3", ... + "x", s.XData, ... + "y", s.YData, ... + "marker", struct("color", "rgba(128,64,0,0.700000)"), ... + "histnorm", "probability", ... + "histfunc", "count", ... + "showlegend", false, ... + "orientation", "h", ... + "nbinsy", s.NumBins(2) ... + )); + try close(); catch; end + end + function testScatterHistPlotData(tc) if is_octave() return % The `scatterhist` function is not yet implemented in Octave. From 1bf64adf798c73952c22b1db3e0373295d68cd41 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sat, 21 Nov 2026 12:27:13 +0000 Subject: [PATCH 6/6] makegallery: add scatterhistogram --- plotly/makegallery.m | 1 + 1 file changed, 1 insertion(+) diff --git a/plotly/makegallery.m b/plotly/makegallery.m index 6788adbf..dc71fbb3 100644 --- a/plotly/makegallery.m +++ b/plotly/makegallery.m @@ -697,6 +697,7 @@ 'stem3', 't = 0:0.2:6*pi; stem3(cos(t), sin(t), t);'; ... 'scatter', 'x = randn(200, 1); y = randn(200, 1); scatter(x, y);'; ... 'scatter3', '[x, y, z] = sphere(20); scatter3(x(:), y(:), z(:));'; ... + 'scatterhistogram', 'x = randn(200, 1); y = randn(200, 1); scatterhistogram(x, y);'; ... 'pie', 'pie([3 5 2 4 6]);'; ... 'pie3', 'pie3([3 5 2 4 6]);'; ... 'compass', 't = 0:pi/8:2*pi; compass(cos(t), sin(t));'; ...