Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7fd37b

Browse files
Fix scatter3d treated as scatter2d
1 parent 45f2b3a commit a7fd37b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

plotly/Test_plotlyfig.m

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,42 @@ function testScatterPlotData(tc)
218218
));
219219
end
220220

221+
function testScatter3DPlotData(tc)
222+
fig = figure("Visible","off");
223+
[X,Y,Z] = sphere(16);
224+
x = [0.5*X(:); 0.75*X(:); X(:)]';
225+
y = [0.5*Y(:); 0.75*Y(:); Y(:)]';
226+
z = [0.5*Z(:); 0.75*Z(:); Z(:)]';
227+
scatter3(x,y,z);
228+
229+
p = plotlyfig(fig,"visible","off");
230+
231+
tc.verifyNumElements(p.data, 1);
232+
tc.verifyEqual(p.data{1}, struct( ...
233+
"type", "scatter3d", ...
234+
"scene", "scene1", ...
235+
"mode", "markers", ...
236+
"visible", true, ...
237+
"name", '', ...
238+
"x", x, ...
239+
"y", y, ...
240+
"z", z, ...
241+
"marker", struct( ...
242+
"sizeref", 1, ...
243+
"sizemode", 'area', ...
244+
"size", 72 * ones(size(x)), ...
245+
"line", struct( ...
246+
"width", 0.7500, ...
247+
"color", 'rgb(0.000000,113.985000,188.955000)' ...
248+
), ...
249+
"symbol", 'circle', ...
250+
"color", "rgba(0,0,0,0)", ...
251+
"opacity", 1 ...
252+
), ...
253+
"showlegend", false ...
254+
));
255+
end
256+
221257
function testHistogramPlotData(tc)
222258
fig = figure("Visible","off");
223259
values = [0.6297 0.9559 0.7551 0.5261 0.8501 0.8160 0.1321 0.7607 0.6172 0.3976];

plotly/plotlyfig_aux/handlegraphics/updateScatter.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function updateScatter(obj,plotIndex)
55
plotData = obj.State.Plot(plotIndex).Handle;
66

77
%-check is 3D scatter-%
8-
isScatter3D = isfield(plotData, "ZData") && ~isempty(plotData.ZData);
8+
isScatter3D = isprop(plotData,"ZData") && ~isempty(plotData.ZData);
99

1010
%-set trace-%
1111
if ~isScatter3D

0 commit comments

Comments
 (0)