Skip to content

Commit e955422

Browse files
bronsolobronsolo
authored andcommitted
new patch, surface, and scatter 3D support
1 parent 3bb33b2 commit e955422

File tree

3 files changed

+59
-35
lines changed

3 files changed

+59
-35
lines changed

plotly/plotlyfig_aux/handlegraphics/updatePatch.m

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@
6969
%-------------------------------------------------------------------------%
7070

7171
%-patch type-%
72-
obj.data{patchIndex}.type = 'scatter';
72+
if any(nonzeros(patch_data.ZData))
73+
obj.data{patchIndex}.type = 'scatter3d';
74+
else
75+
obj.data{patchIndex}.type = 'scatter';
76+
end
7377

7478
%-------------------------------------------------------------------------%
7579

@@ -103,6 +107,24 @@
103107

104108
%-------------------------------------------------------------------------%
105109

110+
%-patch z-%
111+
if any(nonzeros(patch_data.ZData))
112+
zdata = patch_data.ZData;
113+
114+
if isvector(ydata)
115+
obj.data{patchIndex}.z = [zdata' zdata(1)];
116+
else
117+
ztemp = reshape(zdata,[],1);
118+
znew = [];
119+
for n = 1:size(zdata,2)
120+
znew = [znew ; zdata(:,n) ; zdata(1,n); NaN];
121+
end
122+
obj.data{patchIndex}.z = znew;
123+
end
124+
end
125+
126+
%-------------------------------------------------------------------------%
127+
106128
%-patch name-%
107129
if ~isempty(patch_data.DisplayName);
108130
obj.data{patchIndex}.name = patch_data.DisplayName;

plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function updateScattergroup(obj,scatterIndex)
8383
%-------------------------------------------------------------------------%
8484

8585
%-scatter type-%
86-
obj.data{scatterIndex}.type = 'scatter';
86+
if any(nonzeros(scatter_data.ZData))
87+
obj.data{scatterIndex}.type = 'scatter3d';
88+
else
89+
obj.data{scatterIndex}.type = 'scatter';
90+
end
8791

8892
%-------------------------------------------------------------------------%
8993

@@ -128,6 +132,17 @@ function updateScattergroup(obj,scatterIndex)
128132

129133
%---------------------------------------------------------------------%
130134

135+
%-scatter z-%
136+
if any(nonzeros(scatter_data.ZData))
137+
if length(scatter_child_data) > 1
138+
obj.data{scatterIndex}.z(m) = scatter_child_data(n).ZData;
139+
else
140+
obj.data{scatterIndex}.z = scatter_child_data.ZData;
141+
end
142+
end
143+
144+
%---------------------------------------------------------------------%
145+
131146
%-scatter showlegend-%
132147
leg = get(scatter_data.Annotation);
133148
legInfo = get(leg.LegendInformation);

plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,42 +27,29 @@
2727

2828
% check for 3D
2929
if any(nonzeros(image_data.ZData))
30-
31-
%-surface type-%
32-
if ~isvector(image_data.XData) || ~isvector(image_data.YData)
33-
obj.data{surfaceIndex}.type = 'scatter3d';
34-
else
30+
31+
%-surface type-%
3532
obj.data{surfaceIndex}.type = 'surface';
36-
end
37-
38-
%-------------------------------------------------------------------------%
39-
40-
%-surface x-%
41-
obj.data{surfaceIndex}.x = image_data.XData;
42-
43-
if strcmp(obj.data{surfaceIndex}.type,'scatter3d')
44-
obj.data{surfaceIndex}.x = reshape(obj.data{surfaceIndex}.x,1,size(obj.data{surfaceIndex}.x,1)*size(obj.data{surfaceIndex}.x,2));
45-
end
46-
%-------------------------------------------------------------------------%
47-
48-
%-surface y-%
49-
obj.data{surfaceIndex}.y = image_data.YData;
50-
51-
if strcmp(obj.data{surfaceIndex}.type,'scatter3d')
52-
obj.data{surfaceIndex}.y = reshape(obj.data{surfaceIndex}.y,1,size(obj.data{surfaceIndex}.y,1)*size(obj.data{surfaceIndex}.y,2));
53-
end
54-
%-------------------------------------------------------------------------%
55-
56-
%-surface z-%
57-
obj.data{surfaceIndex}.z = image_data.ZData;
58-
59-
if strcmp(obj.data{surfaceIndex}.type,'scatter3d')
60-
obj.data{surfaceIndex}.z = reshape(image_data.ZData,1,size(image_data.ZData,1)*size(image_data.ZData,2));
61-
end
62-
33+
34+
%---------------------------------------------------------------------%
35+
36+
%-surface x-%
37+
obj.data{surfaceIndex}.x = image_data.XData;
38+
39+
%---------------------------------------------------------------------%
40+
41+
%-surface y-%
42+
obj.data{surfaceIndex}.y = image_data.YData;
43+
44+
%---------------------------------------------------------------------%
45+
46+
%-surface z-%
47+
obj.data{surfaceIndex}.z = image_data.ZData;
48+
6349
else
50+
6451
%-surface type-%
65-
obj = updateImage(obj, surfaceIndex);
52+
obj = updateImage(obj, surfaceIndex);
6653

6754
%-surface x-%
6855
obj.data{surfaceIndex}.x = image_data.XData(1,:);

0 commit comments

Comments
 (0)