1
- function obj = updateStem (obj ,dataIndex )
1
+ function obj = updateStem3 (obj ,dataIndex )
2
2
3
- % ------------------------------------------------------------------------%
3
+ % - ------------------------------------------------------------------------%
4
4
5
- % -update line-%
6
- updateLineseries(obj ,dataIndex );
7
- stem_temp_data = obj.data{dataIndex };
8
- isstem3d = obj .PlotOptions .is3d ;
5
+ % -AXIS INDEX-%
6
+ axIndex = obj .getAxisIndex(obj .State .Plot(dataIndex ).AssociatedAxis);
9
7
10
- % ------------------------------------------------------------------------%
8
+ % -PLOT DATA STRUCTURE- %
9
+ data = get(obj .State .Plot(dataIndex ).Handle);
11
10
12
- % -scatter mode -%
13
- stem_temp_data.mode = ' lines+markers ' ;
11
+ % -CHECK FOR MULTIPLE AXES -%
12
+ [ xsource , ysource ] = findSourceAxis( obj , axIndex ) ;
14
13
15
- % ------------------------------------------------------------------------%
14
+ % ------------------------------------------------------------------------%
16
15
17
- % -allocated space for extended data-%
18
- xdata_extended = zeros(1 ,3 * length(stem_temp_data .x ));
19
- ydata_extended = zeros(1 ,3 * length(stem_temp_data .y ));
16
+ % -get coordenate x,y,z data-%
17
+ xdata = data .XData ;
18
+ ydata = data .YData ;
19
+ zdata = data .ZData ;
20
+ npoints = length(xdata );
20
21
21
- if isstem3d
22
- zdata_extended = zeros(1 ,3 * length(stem_temp_data .z ));
23
- end
22
+ % ------------------------------------------------------------------------%
24
23
25
- % -format x data-%
26
- m = 1 ;
27
- for n = 1 : length(stem_temp_data .x )
28
- xdata_extended(m ) = stem_temp_data .x(n );
29
- xdata_extended(m + 1 ) = stem_temp_data .x(n );
24
+ % -check if stem3-%
25
+ isstem3 = ~isempty(zdata );
26
+
27
+ % ------------------------------------------------------------------------%
28
+
29
+ % -SCENE-%
30
+ if isstem3
31
+ eval([' scene = obj.layout.scene' num2str(xsource ) ' ;' ]);
32
+ else
33
+ eval([' xaxis = obj.layout.xaxis' num2str(xsource ) ' ;' ]);
34
+ eval([' yaxis = obj.layout.yaxis' num2str(xsource ) ' ;' ]);
35
+ end
36
+
37
+ % -------------------------------------------------------------------------%
38
+
39
+ % -scatter3d scene-%
40
+ if isstem3
41
+ stem_data.scene = sprintf(' scene%d ' , xsource );
42
+ else
43
+ stem_data.xaxis = sprintf(' x%d ' , xsource );
44
+ stem_data.yaxis = sprintf(' y%d ' , xsource );
45
+ end
46
+
47
+ % ------------------------------------------------------------------------%
48
+
49
+ % -scatter3d type-%
50
+ if isstem3
51
+ stem_data.type = ' scatter3d' ;
52
+ else
53
+ stem_data.type = ' scatter' ;
54
+ end
55
+
56
+ % -------------------------------------------------------------------------%
57
+
58
+ % -scatter3d visible-%
59
+ stem_data.visible = strcmp(data .Visible ,' on' );
60
+
61
+ % -------------------------------------------------------------------------%
62
+
63
+ % -scatter3d name-%
64
+ stem_data.name = data .DisplayName ;
65
+
66
+ % ------------------------------------------------------------------------%
67
+
68
+ % -scatter mode-%
69
+ stem_data.mode = ' lines+markers' ;
70
+
71
+ % ------------------------------------------------------------------------%
72
+
73
+ % -allocated space for extended data-%
74
+ xdata_extended = zeros(3 * npoints , 1 );
75
+ ydata_extended = zeros(3 * npoints , 1 );
76
+
77
+ if isstem3
78
+ zdata_extended = zeros(3 * npoints , 1 );
79
+ end
80
+
81
+ % -format data-%
82
+ m = 1 ;
83
+ for n = 1 : npoints
84
+ % -x data-%
85
+ xdata_extended(m ) = xdata(n );
86
+ xdata_extended(m + 1 ) = xdata(n );
30
87
xdata_extended(m + 2 ) = nan ;
31
- m = m + 3 ;
32
- end
33
88
34
- % -format y data-%
35
- m = 1 ;
36
- for n = 1 : length(stem_temp_data .y )
89
+ % -y data-%
37
90
ydata_extended(m ) = 0 ;
38
-
39
- if isstem3d
40
- ydata_extended(m ) = stem_temp_data .y(n );
91
+ if isstem3
92
+ ydata_extended(m ) = ydata(n );
41
93
end
42
-
43
- ydata_extended(m + 1 ) = stem_temp_data .y(n );
94
+ ydata_extended(m + 1 ) = ydata(n );
44
95
ydata_extended(m + 2 ) = nan ;
96
+
97
+ % -z data-%
98
+ if isstem3
99
+ zdata_extended(m ) = 0 ;
100
+ zdata_extended(m + 1 ) = zdata(n );
101
+ zdata_extended(m + 2 ) = nan ;
102
+ end
103
+
45
104
m = m + 3 ;
46
- end
47
-
48
- % -format z data-%
49
- if isstem3d
50
- m = 1 ;
51
- for n = 1 : length(stem_temp_data .z )
52
- zdata_extended(m ) = 0 ;
53
- zdata_extended(m + 1 ) = stem_temp_data .z(n );
54
- zdata_extended(m + 2 ) = nan ;
55
- m = m + 3 ;
105
+ end
106
+
107
+ % ------------------------------------------------------------------------%
108
+
109
+ % -scatter3d line-%
110
+ stem_data.line = extractLineLine(data );
111
+
112
+ % -------------------------------------------------------------------------%
113
+
114
+ % -scatter3d marker-%
115
+ stem_data.marker = extractLineMarker(data );
116
+
117
+ % -------------------------------------------------------------------------%
118
+
119
+ if isstem3
120
+
121
+ % -fix marker symbol-%
122
+ symbol = stem_data .marker .symbol ;
123
+
124
+ if strcmpi(symbol , ' asterisk-open' ) || strcmpi(symbol , ' cross-thin-open' )
125
+ stem_data.marker.symbol = ' cross' ;
126
+ end
127
+
128
+ stem_data.marker.size = stem_data .marker .size * 0.6 ;
129
+
130
+ % -fix dash line-%
131
+ dash = stem_data .line .dash ;
132
+
133
+ if strcmpi(dash , ' dash' )
134
+ stem_data.line.dash = ' dot' ;
135
+ end
136
+ end
137
+
138
+ % -------------------------------------------------------------------------%
139
+
140
+ % -hide every other marker-%
141
+ markercolor = cell(3 * npoints ,1 );
142
+ linecolor = cell(3 * npoints ,1 );
143
+ hidecolor = ' rgba(0,0,0,0)' ;
144
+
145
+ markercolor(1 : 3 : 3 * npoints ) = {hidecolor };
146
+ markercolor(2 : 3 : 3 * npoints ) = {stem_data .marker .color };
147
+ markercolor(3 : 3 : 3 * npoints ) = {hidecolor };
148
+
149
+ linecolor(1 : 3 : 3 * npoints ) = {hidecolor };
150
+ linecolor(2 : 3 : 3 * npoints ) = {stem_data .marker .line .color };
151
+ linecolor(3 : 3 : 3 * npoints ) = {hidecolor };
152
+
153
+ % -add new marker/line colors-%
154
+ stem_data.marker.color = markercolor ;
155
+ stem_data.marker.line.color = linecolor ;
156
+
157
+ stem_data.marker.line.width = stem_data .marker .line .width * 2 ;
158
+ stem_data.line.width = stem_data .line .width * 2 ;
159
+
160
+ % ------------------------------------------------------------------------%
161
+
162
+ % -set x y z data-%
163
+ stem_data.x = xdata_extended ;
164
+ stem_data.y = ydata_extended ;
165
+
166
+ if isstem3
167
+ stem_data.z = zdata_extended ;
168
+ end
169
+
170
+ % ------------------------------------------------------------------------%
171
+
172
+ % -set plotly data-%
173
+ obj.data{dataIndex } = stem_data ;
174
+
175
+ % ------------------------------------------------------------------------%
176
+
177
+ % -SETTING SCENE-%
178
+
179
+ if isstem3
180
+ % -aspect ratio-%
181
+ asr = obj .PlotOptions .AspectRatio ;
182
+
183
+ if ~isempty(asr )
184
+ if ischar(asr )
185
+ scene.aspectmode = asr ;
186
+ elseif isvector(asr ) && length(asr ) == 3
187
+ xar = asr(1 );
188
+ yar = asr(2 );
189
+ zar = asr(3 );
190
+ end
191
+ else
192
+
193
+ % -define as default-%
194
+ xar = max(xdata(: ));
195
+ yar = max(ydata(: ));
196
+ xyar = max([xar , yar ]);
197
+ xar = xyar ; yar = xyar ;
198
+ zar = 0.7 * max([xar , yar ]);
56
199
end
57
- end
58
200
59
- % -hide every other marker-%
60
- color_temp = cell(1 ,3 * length(stem_temp_data .y ));
61
- line_color_temp = cell(1 ,3 * length(stem_temp_data .y ));
201
+ scene.aspectratio.x = xar ;
202
+ scene.aspectratio.y = yar ;
203
+ scene.aspectratio.z = zar ;
204
+
205
+ % ---------------------------------------------------------------------%
206
+
207
+ % -camera eye-%
208
+ ey = obj .PlotOptions .CameraEye ;
209
+
210
+ if ~isempty(ey )
211
+ if isvector(ey ) && length(ey ) == 3
212
+ scene.camera.eye.x = ey(1 );
213
+ scene.camera.eye.y = ey(2 );
214
+ scene.camera.eye.z = ey(3 );
215
+ end
216
+ else
217
+
218
+ % -define as default-%
219
+ xey = - xar ; if xey > 0 xfac = 0.2 ; else xfac = - 0.2 ; end
220
+ yey = - yar ; if yey > 0 yfac = - 0.2 ; else yfac = 0.2 ; end
221
+ if zar > 0 zfac = 0.2 ; else zfac = - 0.2 ; end
222
+
223
+ scene.camera.eye.x = xey + xfac * xey ;
224
+ scene.camera.eye.y = yey + yfac * yey ;
225
+ scene.camera.eye.z = zar + zfac * zar ;
226
+ end
227
+
228
+ % ---------------------------------------------------------------------%
229
+
230
+ % -zerolines hidded-%
231
+ scene.xaxis.zeroline = false ;
232
+ scene.yaxis.zeroline = false ;
233
+ scene.zaxis.zeroline = false ;
234
+
235
+ scene.xaxis.linecolor = ' rgba(0,0,0,0.8)' ;
236
+ scene.yaxis.linecolor = ' rgba(0,0,0,0.8)' ;
237
+ scene.zaxis.linecolor = ' rgba(0,0,0,0.5)' ;
238
+
239
+ scene.xaxis.ticklen = 5 ;
240
+ scene.yaxis.ticklen = 5 ;
241
+ scene.zaxis.ticklen = 5 ;
242
+
243
+ scene.xaxis.tickcolor = ' rgba(0,0,0,0.8)' ;
244
+ scene.yaxis.tickcolor = ' rgba(0,0,0,0.8)' ;
245
+ scene.zaxis.tickcolor = ' rgba(0,0,0,0.8)' ;
246
+
247
+ scene.xaxis.range = data .Parent .XLim ;
248
+ scene.yaxis.range = data .Parent .YLim ;
249
+ scene.zaxis.range = data .Parent .ZLim ;
62
250
63
- for n = 1 : 3 : length(color_temp )
64
- color_temp{n } = ' rgba(0,0,0,0)' ;
65
- color_temp{n + 1 } = stem_temp_data .marker .color ;
66
- color_temp{n + 2 } = ' rgba(0,0,0,0)' ;
67
- line_color_temp{n } = ' rgba(0,0,0,0)' ;
68
- line_color_temp{n + 1 } = stem_temp_data .marker .line .color ;
69
- line_color_temp{n + 2 } = ' rgba(0,0,0,0)' ;
70
- end
251
+ scene.xaxis.tickvals = data .Parent .XTick ;
252
+ scene.yaxis.tickvals = data .Parent .YTick ;
253
+ scene.zaxis.tickvals = data .Parent .ZTick ;
71
254
72
- % add new marker/line colors
73
- stem_temp_data.marker.color = color_temp ;
74
- stem_temp_data.marker.line.color = line_color_temp ;
255
+ scene.xaxis.title = data . Parent . XLabel . String ;
256
+ scene.yaxis.title = data . Parent . YLabel . String ;
257
+ scene.zaxis.title = data . Parent . ZLabel . String ;
75
258
76
- % ------------------------------------------------------------------------%
259
+ % -update scene-%
260
+ obj.layout = setfield(obj .layout , sprintf(' scene%d ' , xsource ), scene );
77
261
78
- stem_temp_data.x = xdata_extended ;
79
- stem_temp_data.y = ydata_extended ;
262
+ else
263
+ yaxis.zeroline = true ;
80
264
81
- if isstem3d
82
- stem_temp_data.z = zdata_extended ;
83
- end
265
+ xaxis.linecolor = ' rgba(0,0,0,0.4)' ;
266
+ yaxis.linecolor = ' rgba(0,0,0,0.4)' ;
84
267
85
- % ------------------------------------------------------------------------%
268
+ xaxis.tickcolor = ' rgba(0,0,0,0.4)' ;
269
+ yaxis.tickcolor = ' rgba(0,0,0,0.4)' ;
86
270
87
- obj.data{dataIndex } = stem_temp_data ;
271
+ xaxis.tickvals = data .Parent .XTick ;
272
+ yaxis.tickvals = data .Parent .YTick ;
88
273
89
- % ------------------------------------------------------------------------%
274
+ xaxis.title = data .Parent .XLabel .String ;
275
+ yaxis.title = data .Parent .YLabel .String ;
90
276
91
- % -put y-zeroline-%
92
- [~ , ysource ] = findSourceAxis(obj ,dataIndex );
93
- eval([' obj.layout.yaxis' num2str(ysource ) ' .zeroline = true;' ]);
277
+ % -update axis-%
278
+ obj.layout = setfield(obj .layout , sprintf(' xaxis%d ' , xsource ), xaxis );
279
+ obj.layout = setfield(obj .layout , sprintf(' yaxis%d ' , ysource ), yaxis );
280
+ end
94
281
95
- % ------------------------------------------------------------------------%
282
+ % ------------------------------------------------------------------------%
96
283
97
284
end
0 commit comments