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. 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));'; ... diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index 62547144..36fd3fc7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -179,21 +179,21 @@ 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'; 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-% @@ -247,7 +247,8 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.y = ySmooth; %-set other trace properties-% - traceColor = getStringColor(tmpColor(t,:), 0.7); + tmpColor = get(plotData, 'Color'); + traceColor = getStringColor(round(255*tmpColor(t,:)), 0.7); tmpLineStyle = get(plotData, 'LineStyle'); lineStyle = tmpLineStyle(t); 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