Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions plotly/Test_plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions plotly/makegallery.m
Original file line number Diff line number Diff line change
Expand Up @@ -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));'; ...
Expand Down
11 changes: 6 additions & 5 deletions plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m
Original file line number Diff line number Diff line change
Expand Up @@ -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-%
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion plotly/plotlyfig_aux/helpers/specialAxisPlots.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function out = specialAxisPlots()
out = {'polaraxes' 'stackedplot' 'uicontextmenu' 'legend'};
out = {'polaraxes' 'stackedplot' 'scatterhistogram' 'uicontextmenu' 'legend'};
end
Loading