1
+ function updateAnimatedLine(obj ,plotIndex )
2
+
3
+ % ----SCATTER FIELDS----%
4
+
5
+ % x - [DONE]
6
+ % y - [DONE]
7
+ % r - [HANDLED BY SCATTER]
8
+ % t - [HANDLED BY SCATTER]
9
+ % mode - [DONE]
10
+ % name - [NOT SUPPORTED IN MATLAB]
11
+ % text - [DONE]
12
+ % error_y - [HANDLED BY ERRORBAR]
13
+ % error_x - [NOT SUPPORTED IN MATLAB]
14
+ % connectgaps - [NOT SUPPORTED IN MATLAB]
15
+ % fill - [HANDLED BY AREA]
16
+ % fillcolor - [HANDLED BY AREA]
17
+ % opacity --- [TODO]
18
+ % textfont - [NOT SUPPORTED IN MATLAB]
19
+ % textposition - [NOT SUPPORTED IN MATLAB]
20
+ % xaxis [DONE]
21
+ % yaxis [DONE]
22
+ % showlegend [DONE]
23
+ % stream - [HANDLED BY PLOTLYSTREAM]
24
+ % visible [DONE]
25
+ % type [DONE]
26
+
27
+ % MARKER
28
+ % marler.color - [DONE]
29
+ % marker.size - [DONE]
30
+ % marker.line.color - [DONE]
31
+ % marker.line.width - [DONE]
32
+ % marker.line.dash - [NOT SUPPORTED IN MATLAB]
33
+ % marker.line.opacity - [NOT SUPPORTED IN MATLAB]
34
+ % marker.line.smoothing - [NOT SUPPORTED IN MATLAB]
35
+ % marker.line.shape - [NOT SUPPORTED IN MATLAB]
36
+ % marker.opacity --- [TODO]
37
+ % marker.colorscale - [NOT SUPPORTED IN MATLAB]
38
+ % marker.sizemode - [NOT SUPPORTED IN MATLAB]
39
+ % marker.sizeref - [NOT SUPPORTED IN MATLAB]
40
+ % marker.maxdisplayed - [NOT SUPPORTED IN MATLAB]
41
+
42
+ % LINE
43
+
44
+ % line.color - [DONE]
45
+ % line.width - [DONE]
46
+ % line.dash - [DONE]
47
+ % line.opacity --- [TODO]
48
+ % line.smoothing - [NOT SUPPORTED IN MATLAB]
49
+ % line.shape - [NOT SUPPORTED IN MATLAB]
50
+
51
+ % -------------------------------------------------------------------------%
52
+
53
+ % -AXIS INDEX-%
54
+ axIndex = obj .getAxisIndex(obj .State .Plot(plotIndex ).AssociatedAxis);
55
+
56
+ animLine = obj .State .Plot(plotIndex ).AssociatedAxis.Children(plotIndex );
57
+
58
+ % -PLOT DATA STRUCTURE- %
59
+ plot_data = get(obj .State .Plot(plotIndex ).Handle);
60
+
61
+ % -CHECK FOR MULTIPLE AXES-%
62
+ [xsource , ysource ] = findSourceAxis(obj ,axIndex );
63
+
64
+ % -AXIS DATA-%
65
+ eval([' xaxis = obj.layout.xaxis' num2str(xsource ) ' ;' ]);
66
+ eval([' yaxis = obj.layout.yaxis' num2str(ysource ) ' ;' ]);
67
+
68
+ % -------------------------------------------------------------------------%
69
+
70
+ % -if polar plot or not-%
71
+ treatas = obj .PlotOptions .TreatAs ;
72
+ ispolar = strcmpi(treatas , ' compass' ) || strcmpi(treatas , ' ezpolar' );
73
+
74
+ % -------------------------------------------------------------------------%
75
+
76
+ % -getting data-%
77
+ [x ,y ] = getpoints(animLine );
78
+
79
+ % -------------------------------------------------------------------------%
80
+
81
+ % -scatter xaxis-%
82
+ obj.data{plotIndex }.xaxis = [' x' num2str(xsource )];
83
+
84
+ % -------------------------------------------------------------------------%
85
+
86
+ % -scatter yaxis-%
87
+ obj.data{plotIndex }.yaxis = [' y' num2str(ysource )];
88
+
89
+ % -------------------------------------------------------------------------%
90
+
91
+ % -scatter type-%
92
+ obj.data{plotIndex }.type = ' scatter' ;
93
+
94
+ if ispolar
95
+ obj.data{plotIndex }.type = ' scatterpolar' ;
96
+ end
97
+
98
+ % -------------------------------------------------------------------------%
99
+
100
+ % -scatter visible-%
101
+ obj.data{plotIndex }.visible = strcmp(plot_data .Visible ,' on' );
102
+
103
+ % -------------------------------------------------------------------------%
104
+
105
+ % -scatter x-%
106
+
107
+ if ispolar
108
+ r = sqrt(x .^ 2 + y .^ 2 );
109
+ obj.data{plotIndex }.r = r ;
110
+ else
111
+ obj.data{plotIndex }.x = x(1 );
112
+ end
113
+
114
+ % -------------------------------------------------------------------------%
115
+
116
+ % -scatter y-%
117
+ if ispolar
118
+ theta = atan2(x ,y );
119
+ obj.data{plotIndex }.theta = -(rad2deg(theta ) - 90 );
120
+ else
121
+ obj.data{plotIndex }.y = y(1 );
122
+ end
123
+
124
+ % -------------------------------------------------------------------------%
125
+
126
+ % -Fro 3D plots-%
127
+ obj.PlotOptions.is3d = false ; % by default
128
+
129
+ if isfield(plot_data ,' ZData' )
130
+
131
+ numbset = unique(plot_data .ZData );
132
+
133
+ if any(plot_data .ZData ) && length(numbset )>1
134
+ % -scatter z-%
135
+ obj.data{plotIndex }.z = plot_data .ZData ;
136
+
137
+ % -overwrite type-%
138
+ obj.data{plotIndex }.type = ' scatter3d' ;
139
+
140
+ % -flag to manage 3d plots-%
141
+ obj.PlotOptions.is3d = true ;
142
+ end
143
+ end
144
+
145
+ % -------------------------------------------------------------------------%
146
+
147
+ % -scatter name-%
148
+ obj.data{plotIndex }.name = plot_data .DisplayName ;
149
+
150
+ % -------------------------------------------------------------------------%
151
+
152
+ % -scatter mode-%
153
+ if ~strcmpi(' none' , plot_data .Marker ) ...
154
+ && ~strcmpi(' none' , plot_data .LineStyle )
155
+ mode = ' lines+markers' ;
156
+ elseif ~strcmpi(' none' , plot_data .Marker )
157
+ mode = ' markers' ;
158
+ elseif ~strcmpi(' none' , plot_data .LineStyle )
159
+ mode = ' lines' ;
160
+ else
161
+ mode = ' none' ;
162
+ end
163
+
164
+ obj.data{plotIndex }.mode = mode ;
165
+
166
+ % -------------------------------------------------------------------------%
167
+
168
+ % -scatter line-%
169
+ obj.data{plotIndex }.line = extractLineLine(plot_data );
170
+
171
+ % -------------------------------------------------------------------------%
172
+
173
+ % -scatter marker-%
174
+ obj.data{plotIndex }.marker = extractLineMarker(plot_data );
175
+
176
+ % -------------------------------------------------------------------------%
177
+
178
+ % -scatter showlegend-%
179
+ leg = get(plot_data .Annotation );
180
+ legInfo = get(leg .LegendInformation );
181
+
182
+ switch legInfo .IconDisplayStyle
183
+ case ' on'
184
+ showleg = true ;
185
+ case ' off'
186
+ showleg = false ;
187
+ end
188
+
189
+ obj.data{plotIndex }.showlegend = showleg ;
190
+
191
+ % -------------------------------------------------------------------------%
192
+ % - Play Button Options-%
193
+
194
+ opts{1 } = nan ;
195
+ opts{2 }.frame.duration = 0 ;
196
+ opts{2 }.frame.redraw = false ;
197
+ opts{2 }.mode = ' immediate' ;
198
+ opts{2 }.transition.duration = 0 ;
199
+
200
+ button{1 }.label = ' ▶' ;
201
+ button{1 }.method = ' animate' ;
202
+ button{1 }.args = opts ;
203
+
204
+ obj.layout.updatemenus{1 }.type = ' buttons' ;
205
+ obj.layout.updatemenus{1 }.buttons = button ;
206
+ obj.layout.updatemenus{1 }.pad.r = 70 ;
207
+ obj.layout.updatemenus{1 }.pad.t = 10 ;
208
+ obj.layout.updatemenus{1 }.direction = ' left' ;
209
+ obj.layout.updatemenus{1 }.showactive = true ;
210
+ obj.layout.updatemenus{1 }.x = 0.01 ;
211
+ obj.layout.updatemenus{1 }.y = 0.01 ;
212
+ obj.layout.updatemenus{1 }.xanchor = ' left' ;
213
+ obj.layout.updatemenus{1 }.yanchor = ' top' ;
214
+
215
+ DD{plotIndex } = obj.data{plotIndex };
216
+
217
+ for i = 1 : length(x )
218
+ DD{plotIndex }.x= x(1 : i );
219
+ DD{plotIndex }.y= y(1 : i );
220
+ obj.frames{end + 1 } = struct(' name' ,[' f' ,num2str(i )],' data' ,{DD });
221
+ end
222
+
223
+ end
0 commit comments