11function updatePie3(obj ,plotIndex )
22
3- % -update according to patch or surface-%
4- if strcmpi(obj .State .Plot(plotIndex ).Class, ' patch' )
5- updatePatchPie3(obj , plotIndex );
6- else
7- updateSurfacePie3(obj , plotIndex );
8- end
9-
10- % -hide axis-x-%
11- obj.PlotOptions.scene.xaxis.title = ' ' ;
12- obj.PlotOptions.scene.xaxis.autotick = false ;
13- obj.PlotOptions.scene.xaxis.zeroline = false ;
14- obj.PlotOptions.scene.xaxis.showline = false ;
15- obj.PlotOptions.scene.xaxis.showticklabels = false ;
16- obj.PlotOptions.scene.xaxis.showgrid = false ;
17-
18- % -hide axis-y-%
19- obj.PlotOptions.scene.yaxis.title = ' ' ;
20- obj.PlotOptions.scene.yaxis.autotick = false ;
21- obj.PlotOptions.scene.yaxis.zeroline = false ;
22- obj.PlotOptions.scene.yaxis.showline = false ;
23- obj.PlotOptions.scene.yaxis.showticklabels = false ;
24- obj.PlotOptions.scene.yaxis.showgrid = false ;
25-
26- % -hide axis-z-%
27- obj.PlotOptions.scene.zaxis.title = ' ' ;
28- obj.PlotOptions.scene.zaxis.autotick = false ;
29- obj.PlotOptions.scene.zaxis.zeroline = false ;
30- obj.PlotOptions.scene.zaxis.showline = false ;
31- obj.PlotOptions.scene.zaxis.showticklabels = false ;
32- obj.PlotOptions.scene.zaxis.showgrid = false ;
33-
34- % -put text-%
35- obj.data{plotIndex }.hoverinfo = ' text' ;
36- obj.data{plotIndex }.hovertext = obj .PlotOptions .perc ;
3+ % -update according to patch or surface-%
4+ if strcmpi(obj .State .Plot(plotIndex ).Class, ' patch' )
5+ updatePatchPie3(obj , plotIndex );
6+ else
7+ updateSurfacePie3(obj , plotIndex );
8+ end
379
38- obj.layout = setfield(obj .layout ,[' scene' obj .PlotOptions .scene_anchor(end )], obj .PlotOptions .scene );
39- obj.data{plotIndex }.scene = obj .PlotOptions .scene_anchor ;
10+ % -hide axis-x-%
11+ obj.PlotOptions.scene.xaxis.title = ' ' ;
12+ obj.PlotOptions.scene.xaxis.autotick = false ;
13+ obj.PlotOptions.scene.xaxis.zeroline = false ;
14+ obj.PlotOptions.scene.xaxis.showline = false ;
15+ obj.PlotOptions.scene.xaxis.showticklabels = false ;
16+ obj.PlotOptions.scene.xaxis.showgrid = false ;
17+
18+ % -hide axis-y-%
19+ obj.PlotOptions.scene.yaxis.title = ' ' ;
20+ obj.PlotOptions.scene.yaxis.autotick = false ;
21+ obj.PlotOptions.scene.yaxis.zeroline = false ;
22+ obj.PlotOptions.scene.yaxis.showline = false ;
23+ obj.PlotOptions.scene.yaxis.showticklabels = false ;
24+ obj.PlotOptions.scene.yaxis.showgrid = false ;
25+
26+ % -hide axis-z-%
27+ obj.PlotOptions.scene.zaxis.title = ' ' ;
28+ obj.PlotOptions.scene.zaxis.autotick = false ;
29+ obj.PlotOptions.scene.zaxis.zeroline = false ;
30+ obj.PlotOptions.scene.zaxis.showline = false ;
31+ obj.PlotOptions.scene.zaxis.showticklabels = false ;
32+ obj.PlotOptions.scene.zaxis.showgrid = false ;
33+
34+ % -put text-%
35+ obj.data{plotIndex }.hoverinfo = ' text' ;
36+ obj.data{plotIndex }.hovertext = obj .PlotOptions .perc ;
37+
38+ % -update scene-%
39+ obj.layout = setfield(obj .layout ,[' scene' obj .PlotOptions .scene_anchor(end )], obj .PlotOptions .scene );
40+ obj.data{plotIndex }.scene = obj .PlotOptions .scene_anchor ;
41+ obj.data{plotIndex }.legendgroup = obj .PlotOptions .scene_anchor ;
42+
43+ % -update legend-%
44+ obj.layout.legend.tracegroupgap = 20 ;
45+ obj.layout.legend.traceorder = ' grouped' ;
46+ obj.layout.legend.bordercolor = ' rgb(200,200,200)' ;
47+ obj.layout.legend.x = 0.8 ;
48+ obj.layout.legend.y = 0.5 ;
49+ obj.layout.legend.borderwidth = 0.5 ;
4050
4151end
4252
@@ -53,15 +63,15 @@ function updatePie3(obj,plotIndex)
5363
5464 % -get the percentage-%
5565 if ~any(nonzeros(patch_data .ZData ))
56- t1 = atan2(patch_data .YData(2 ), patch_data .XData(2 ));
57- t2 = atan2(patch_data .YData(end - 1 ), patch_data .XData(end - 1 ));
58-
59- a = rad2deg(t2 - t1 );
60- if a < 0
61- a = a + 360 ;
62- end
63-
64- obj.PlotOptions.perc = sprintf(' %d %% ' , round(100 * a / 360 ));
66+ t1 = atan2(patch_data .YData(2 ), patch_data .XData(2 ));
67+ t2 = atan2(patch_data .YData(end - 1 ), patch_data .XData(end - 1 ));
68+
69+ a = rad2deg(t2 - t1 );
70+ if a < 0
71+ a = a + 360 ;
72+ end
73+
74+ obj.PlotOptions.perc = sprintf(' %d %% ' , round(100 * a / 360 ));
6575 end
6676
6777 % -CHECK FOR MULTIPLE AXES-%
@@ -86,29 +96,29 @@ function updatePie3(obj,plotIndex)
8696 % -patch x-%
8797 xdata = patch_data .XData ;
8898 if isvector(xdata )
89- obj.data{patchIndex }.x = [xdata ' xdata(1 )];
99+ obj.data{patchIndex }.x = [xdata ' xdata(1 )];
90100 else
91- xtemp = reshape(xdata ,[],1 );
92- xnew = [];
93- for n = 1 : size(xdata ,2 )
94- xnew = [xnew ; xdata(: ,n ) ; xdata(1 ,n ); NaN ];
95- end
96- obj.data{patchIndex }.x = xnew ;
101+ xtemp = reshape(xdata ,[],1 );
102+ xnew = [];
103+ for n = 1 : size(xdata ,2 )
104+ xnew = [xnew ; xdata(: ,n ) ; xdata(1 ,n ); NaN ];
105+ end
106+ obj.data{patchIndex }.x = xnew ;
97107 end
98108
99109 % ---------------------------------------------------------------------%
100110
101111 % -patch y-%
102112 ydata = patch_data .YData ;
103113 if isvector(ydata )
104- obj.data{patchIndex }.y = [ydata ' ydata(1 )];
114+ obj.data{patchIndex }.y = [ydata ' ydata(1 )];
105115 else
106- ytemp = reshape(ydata ,[],1 );
107- ynew = [];
108- for n = 1 : size(ydata ,2 )
109- ynew = [ynew ; ydata(: ,n ) ; ydata(1 ,n ); NaN ];
110- end
111- obj.data{patchIndex }.y = ynew ;
116+ ytemp = reshape(ydata ,[],1 );
117+ ynew = [];
118+ for n = 1 : size(ydata ,2 )
119+ ynew = [ynew ; ydata(: ,n ) ; ydata(1 ,n ); NaN ];
120+ end
121+ obj.data{patchIndex }.y = ynew ;
112122 end
113123
114124 % ---------------------------------------------------------------------%
@@ -117,23 +127,23 @@ function updatePie3(obj,plotIndex)
117127 zdata = patch_data .ZData ;
118128
119129 if isvector(ydata )
120- obj.data{patchIndex }.z = [zdata ' zdata(1 )];
130+ obj.data{patchIndex }.z = [zdata ' zdata(1 )];
121131 else
122- ztemp = reshape(zdata ,[],1 );
123- znew = [];
124- for n = 1 : size(zdata ,2 )
125- znew = [znew ; zdata(: ,n ) ; zdata(1 ,n ); NaN ];
126- end
127- obj.data{patchIndex }.z = znew ;
132+ ztemp = reshape(zdata ,[],1 );
133+ znew = [];
134+ for n = 1 : size(zdata ,2 )
135+ znew = [znew ; zdata(: ,n ) ; zdata(1 ,n ); NaN ];
136+ end
137+ obj.data{patchIndex }.z = znew ;
128138 end
129139
130140 % ---------------------------------------------------------------------%
131141
132142 % -patch name-%
133143 if ~isempty(patch_data .DisplayName )
134- obj.data{patchIndex }.name = patch_data .DisplayName ;
144+ obj.data{patchIndex }.name = patch_data .DisplayName ;
135145 else
136- obj.data{patchIndex }.name = patch_data .DisplayName ;
146+ obj.data{patchIndex }.name = patch_data .DisplayName ;
137147 end
138148
139149 % ---------------------------------------------------------------------%
@@ -144,17 +154,17 @@ function updatePie3(obj,plotIndex)
144154 % ---------------------------------------------------------------------%
145155
146156 % -patch fill-%
147- % obj.data{patchIndex}.fill = 'tozeroy';
157+ % obj.data{patchIndex}.fill = 'tozeroy';
148158
149159 % -PATCH MODE-%
150160 if ~strcmpi(' none' , patch_data .Marker ) && ~strcmpi(' none' , patch_data .LineStyle )
151- mode = ' lines+markers' ;
161+ mode = ' lines+markers' ;
152162 elseif ~strcmpi(' none' , patch_data .Marker )
153- mode = ' markers' ;
163+ mode = ' markers' ;
154164 elseif ~strcmpi(' none' , patch_data .LineStyle )
155- mode = ' lines' ;
165+ mode = ' lines' ;
156166 else
157- mode = ' none' ;
167+ mode = ' none' ;
158168 end
159169
160170 obj.data{patchIndex }.mode = mode ;
@@ -173,21 +183,19 @@ function updatePie3(obj,plotIndex)
173183
174184 % -patch fillcolor-%
175185 fill = extractPatchFace(patch_data );
186+ obj.data{patchIndex }.surfacecolor = fill .color ;
176187
177- if strcmp(obj.data{patchIndex }.type,' scatter' )
178- obj.data{patchIndex }.fillcolor = fill .color ;
179- else
180- obj.data{patchIndex }.surfacecolor = fill .color ;
188+ if zdata(1 ) == 0
189+ obj.data{patchIndex }.line.width = 3 ;
190+ obj.data{patchIndex }.line.color = fill .color ;
181191 end
182192
183193 % ---------------------------------------------------------------------%
184194
185195 % -surfaceaxis-%
186- if strcmp(obj.data{patchIndex }.type,' scatter3d' )
187- minstd = min([std(patch_data .XData ) std(patch_data .YData ) std(patch_data .ZData )]);
188- ind = find([std(patch_data .XData ) std(patch_data .YData ) std(patch_data .ZData )] == minstd )-1 ;
189- obj.data{patchIndex }.surfaceaxis = ind ;
190- end
196+ minstd = min([std(patch_data .XData ) std(patch_data .YData ) std(patch_data .ZData )]);
197+ ind = find([std(patch_data .XData ) std(patch_data .YData ) std(patch_data .ZData )] == minstd )-1 ;
198+ obj.data{patchIndex }.surfaceaxis = ind ;
191199
192200 % -------------------------------------------------------------------------%
193201
@@ -196,10 +204,10 @@ function updatePie3(obj,plotIndex)
196204 legInfo = get(leg .LegendInformation );
197205
198206 switch legInfo .IconDisplayStyle
199- case ' on'
200- showleg = true ;
201- case ' off'
202- showleg = false ;
207+ case ' on'
208+ showleg = true ;
209+ case ' off'
210+ showleg = false ;
203211 end
204212
205213 obj.data{patchIndex }.showlegend = showleg ;
@@ -253,8 +261,8 @@ function updatePie3(obj,plotIndex)
253261 len = length(cmap )-1 ;
254262
255263 for c = 1 : length(cmap )
256- col = 255 * cmap(c , : );
257- obj.data{surfaceIndex }.colorscale{c } = { (c - 1 )/len , [' rgb(' num2str(col(1 )) ' ,' num2str(col(2 )) ' ,' num2str(col(3 )) ' )' ] };
264+ col = 255 * cmap(c , : );
265+ obj.data{surfaceIndex }.colorscale{c } = { (c - 1 )/len , [' rgb(' num2str(col(1 )) ' ,' num2str(col(2 )) ' ,' num2str(col(3 )) ' )' ] };
258266 end
259267
260268 obj.data{surfaceIndex }.surfacecolor = 255 *(image_data .CData - 1 ) / (obj.PlotOptions.nbars{xsource } - 1 );
@@ -271,19 +279,19 @@ function updatePie3(obj,plotIndex)
271279 ar = obj .PlotOptions .AspectRatio ;
272280
273281 if ~isempty(ar )
274- if ischar(ar )
275- scene.aspectmode = ar ;
276- elseif isvector(ar ) && length(ar ) == 3
277- xar = ar(1 );
278- yar = ar(2 );
279- zar = ar(3 );
280- end
282+ if ischar(ar )
283+ scene.aspectmode = ar ;
284+ elseif isvector(ar ) && length(ar ) == 3
285+ xar = ar(1 );
286+ yar = ar(2 );
287+ zar = ar(3 );
288+ end
281289 else
282290
283- % -define as default-%
284- xar = max(xdata(: ));
285- yar = max(ydata(: ));
286- zar = max([xar , yar ]);
291+ % -define as default-%
292+ xar = max(xdata(: ));
293+ yar = max(ydata(: ));
294+ zar = max([xar , yar ]);
287295 end
288296
289297 fac1 = 0.75 ;
@@ -305,21 +313,21 @@ function updatePie3(obj,plotIndex)
305313 ey = obj .PlotOptions .CameraEye ;
306314
307315 if ~isempty(ey )
308- if isvector(ey ) && length(ey ) == 3
309- scene.camera.eye.x = ey(1 );
310- scene.camera.eye.y = ey(2 );
311- scene.camera.eye.z = ey(3 );
312- end
316+ if isvector(ey ) && length(ey ) == 3
317+ scene.camera.eye.x = ey(1 );
318+ scene.camera.eye.y = ey(2 );
319+ scene.camera.eye.z = ey(3 );
320+ end
313321 else
314322
315- % -define as default-%
316- xey = - xar ; if xey > 0 xfac = - 0.2 ; else xfac = 0.2 ; end
317- yey = - yar ; if yey > 0 yfac = - 0.2 ; else yfac = 0.2 ; end
318- if zar > 0 zfac = 0.2 ; else zfac = - 0.2 ; end
319-
320- scene.camera.eye.x = xey + xfac * xey ;
321- scene.camera.eye.y = yey + yfac * yey ;
322- scene.camera.eye.z = zar + zfac * zar ;
323+ % -define as default-%
324+ xey = - xar ; if xey > 0 xfac = - 0.2 ; else xfac = 0.2 ; end
325+ yey = - yar ; if yey > 0 yfac = - 0.2 ; else yfac = 0.2 ; end
326+ if zar > 0 zfac = 0.2 ; else zfac = - 0.2 ; end
327+
328+ scene.camera.eye.x = xey + xfac * xey ;
329+ scene.camera.eye.y = yey + yfac * yey ;
330+ scene.camera.eye.z = zar + zfac * zar ;
323331 end
324332
325333 % -------------------------------------------------------------------------%
@@ -331,6 +339,7 @@ function updatePie3(obj,plotIndex)
331339
332340 % -surface name-%
333341 obj.data{surfaceIndex }.name = image_data .DisplayName ;
342+ obj.data{surfaceIndex - 1 }.name = image_data .DisplayName ;
334343
335344 % -------------------------------------------------------------------------%
336345
@@ -348,13 +357,14 @@ function updatePie3(obj,plotIndex)
348357 legInfo = get(leg .LegendInformation );
349358
350359 switch legInfo .IconDisplayStyle
351- case ' on'
352- showleg = true ;
353- case ' off'
354- showleg = false ;
360+ case ' on'
361+ showleg = true ;
362+ case ' off'
363+ showleg = false ;
355364 end
356365
357- obj.data{surfaceIndex }.showlegend = showleg ;
366+ obj.data{surfaceIndex - 1 }.showlegend = showleg ;
367+ obj.data{surfaceIndex }.showlegend = false ;
358368
359369 % -------------------------------------------------------------------------%
360370end
0 commit comments