|
1 | 1 | function updateScatter(obj,scatterIndex)
|
2 | 2 |
|
3 |
| -%check: http://undocumentedmatlab.com/blog/undocumented-scatter-plot-behavior |
4 |
| - |
5 |
| -%----SCATTER FIELDS----% |
6 |
| - |
7 |
| -% x - [DONE] |
8 |
| -% y - [DONE] |
9 |
| -% r - [HANDLED BY SCATTER] |
10 |
| -% t - [HANDLED BY SCATTER] |
11 |
| -% mode - [DONE] |
12 |
| -% name - [DONE] |
13 |
| -% text - [NOT SUPPORTED IN MATLAB] |
14 |
| -% error_y - [HANDLED BY ERRORBAR] |
15 |
| -% error_x - [NOT SUPPORTED IN MATLAB] |
16 |
| -% textfont - [NOT SUPPORTED IN MATLAB] |
17 |
| -% textposition - [NOT SUPPORTED IN MATLAB] |
18 |
| -% xaxis [DONE] |
19 |
| -% yaxis [DONE] |
20 |
| -% showlegend [DONE] |
21 |
| -% stream - [HANDLED BY PLOTLYSTREAM] |
22 |
| -% visible [DONE] |
23 |
| -% type [DONE] |
24 |
| -% opacity ---[TODO] |
25 |
| - |
26 |
| -% MARKER |
27 |
| -% marler.color - [DONE] |
28 |
| -% marker.size - [DONE] |
29 |
| -% marker.opacity - [NOT SUPPORTED IN MATLAB] |
30 |
| -% marker.colorscale - [NOT SUPPORTED IN MATLAB] |
31 |
| -% marker.sizemode - [DONE] |
32 |
| -% marker.sizeref - [DONE] |
33 |
| -% marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] |
34 |
| - |
35 |
| -% MARKER LINE |
36 |
| -% marker.line.color - [DONE] |
37 |
| -% marker.line.width - [DONE] |
38 |
| -% marker.line.dash - [NOT SUPPORTED IN MATLAB] |
39 |
| -% marker.line.opacity - [DONE] |
40 |
| -% marker.line.smoothing - [NOT SUPPORTED IN MATLAB] |
41 |
| -% marker.line.shape - [NOT SUPPORTED IN MATLAB] |
42 |
| - |
43 |
| -% LINE |
44 |
| -% line.color - [NA] |
45 |
| -% line.width - [NA] |
46 |
| -% line.dash - [NA] |
47 |
| -% line.opacity [NA] |
48 |
| -% line.smoothing - [NOT SUPPORTED IN MATLAB] |
49 |
| -% line.shape - [NOT SUPPORTED IN MATLAB] |
50 |
| -% connectgaps - [NOT SUPPORTED IN MATLAB] |
51 |
| -% fill - [HANDLED BY AREA] |
52 |
| -% fillcolor - [HANDLED BY AREA] |
53 |
| - |
54 |
| -%-AXIS INDEX-% |
55 |
| -axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); |
56 |
| - |
57 |
| -%-SCATTER DATA STRUCTURE- % |
58 |
| -scatter_data = get(obj.State.Plot(scatterIndex).Handle); |
59 |
| - |
60 |
| -%-CHECK FOR MULTIPLE AXES-% |
61 |
| -[xsource, ysource] = findSourceAxis(obj,axIndex); |
62 |
| - |
63 |
| -if isfield(scatter_data,'ZData') |
64 |
| - if isempty(scatter_data.ZData) |
65 |
| - |
66 |
| - %-AXIS DATA-% |
67 |
| - eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); |
68 |
| - eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); |
69 |
| - |
70 |
| - %-------------------------------------------------------------------------% |
71 |
| - |
72 |
| - %-scatter xaxis-% |
73 |
| - obj.data{scatterIndex}.xaxis = ['x' num2str(xsource)]; |
74 |
| - |
75 |
| - %-------------------------------------------------------------------------% |
76 |
| - |
77 |
| - %-scatter yaxis-% |
78 |
| - obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)]; |
| 3 | + %-------------------------------------------------------------------------% |
| 4 | + |
| 5 | + %-INITIALIZATIONS-% |
| 6 | + axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); |
| 7 | + [xSource, ySource] = findSourceAxis(obj,axIndex); |
| 8 | + scatterData = get(obj.State.Plot(scatterIndex).Handle) |
| 9 | + |
| 10 | + try |
| 11 | + isScatter3D = isfield(scatterData,'ZData'); |
| 12 | + isScatter3D = isScatter3D & ~isempty(scatterData.ZData); |
| 13 | + catch |
| 14 | + isScatter3D = false; |
79 | 15 | end
|
| 16 | + %-------------------------------------------------------------------------% |
80 | 17 |
|
81 |
| -end |
82 |
| - |
83 |
| -%-------------------------------------------------------------------------% |
84 |
| - |
85 |
| -%-scatter type-% |
86 |
| -obj.data{scatterIndex}.type = 'scatter'; |
87 |
| - |
88 |
| -%-------------------------------------------------------------------------% |
89 |
| - |
90 |
| -%-scatter mode-% |
91 |
| -obj.data{scatterIndex}.mode = 'markers'; |
92 |
| - |
93 |
| -%-------------------------------------------------------------------------% |
94 |
| - |
95 |
| -%-scatter visible-% |
96 |
| -obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); |
97 |
| - |
98 |
| -%-------------------------------------------------------------------------% |
99 |
| - |
100 |
| -%-scatter name-% |
101 |
| -obj.data{scatterIndex}.name = scatter_data.DisplayName; |
| 18 | + %-set trace-% |
| 19 | + if ~isScatter3D |
| 20 | + obj.data{scatterIndex}.type = 'scatter'; |
| 21 | + obj.data{scatterIndex}.xaxis = sprintf('x%d', xSource); |
| 22 | + obj.data{scatterIndex}.yaxis = sprintf('y%d', ySource); |
| 23 | + else |
| 24 | + obj.data{scatterIndex}.type = 'scatter3d'; |
| 25 | + obj.data{scatterIndex}.scene = sprintf('scene%d', xSource); |
| 26 | + end |
102 | 27 |
|
103 |
| -%-------------------------------------------------------------------------% |
| 28 | + obj.data{scatterIndex}.mode = 'markers'; |
| 29 | + obj.data{scatterIndex}.visible = strcmp(scatterData.Visible,'on'); |
| 30 | + obj.data{scatterIndex}.name = scatterData.DisplayName; |
104 | 31 |
|
105 |
| -%-scatter patch data-% |
106 |
| -for m = 1:length(scatter_data) |
| 32 | + %-------------------------------------------------------------------------% |
| 33 | + |
| 34 | + %-set plot data-% |
| 35 | + obj.data{scatterIndex}.x = scatterData.XData; |
| 36 | + obj.data{scatterIndex}.y = scatterData.YData; |
107 | 37 |
|
108 |
| - %reverse counter |
109 |
| - n = length(scatter_data) - m + 1; |
110 |
| - |
111 |
| - %---------------------------------------------------------------------% |
112 |
| - |
113 |
| - %-scatter x-% |
114 |
| - if length(scatter_data) > 1 |
115 |
| - obj.data{scatterIndex}.x(m) = scatter_data(n).XData; |
116 |
| - else |
117 |
| - obj.data{scatterIndex}.x = scatter_data.XData; |
118 |
| - end |
119 |
| - |
120 |
| - %---------------------------------------------------------------------% |
121 |
| - |
122 |
| - %-scatter y-% |
123 |
| - if length(scatter_data) > 1 |
124 |
| - obj.data{scatterIndex}.y(m) = scatter_data(n).YData; |
125 |
| - else |
126 |
| - obj.data{scatterIndex}.y = scatter_data.YData; |
| 38 | + if isScatter3D |
| 39 | + obj.data{scatterIndex}.z = scatterData.ZData; |
127 | 40 | end
|
| 41 | + |
| 42 | + %-------------------------------------------------------------------------% |
128 | 43 |
|
129 |
| - %---------------------------------------------------------------------% |
130 |
| - |
131 |
| - %-scatter z-% |
132 |
| - if isHG2() |
133 |
| - if isfield(scatter_data,'ZData') |
134 |
| - if any(scatter_data.ZData) |
135 |
| - if length(scatter_data) > 1 |
136 |
| - obj.data{scatterIndex}.z(m) = scatter_data(n).ZData; |
137 |
| - else |
138 |
| - obj.data{scatterIndex}.z = scatter_data.ZData; |
139 |
| - end |
140 |
| - % overwrite type |
141 |
| - obj.data{scatterIndex}.type = 'scatter3d'; |
142 |
| - end |
143 |
| - end |
| 44 | + %-set marker property-% |
| 45 | + obj.data{scatterIndex}.marker = extractScatterMarker(scatterData); |
| 46 | + markerSize = obj.data{scatterIndex}.marker.size; |
| 47 | + markerColor = obj.data{scatterIndex}.marker.color; |
| 48 | + markerLineColor = obj.data{scatterIndex}.marker.line.color; |
| 49 | + |
| 50 | + if length(markerSize) == 1 |
| 51 | + obj.data{scatterIndex}.marker.size = markerSize * 0.15; |
144 | 52 | end
|
145 |
| - |
146 |
| - %---------------------------------------------------------------------% |
147 |
| - |
148 |
| - %-scatter showlegend-% |
149 |
| - leg = get(scatter_data.Annotation); |
150 |
| - legInfo = get(leg.LegendInformation); |
151 |
| - |
152 |
| - switch legInfo.IconDisplayStyle |
153 |
| - case 'on' |
154 |
| - showleg = true; |
155 |
| - case 'off' |
156 |
| - showleg = false; |
| 53 | + |
| 54 | + if length(markerColor) == 1 |
| 55 | + obj.data{scatterIndex}.marker.color = markerColor{1} |
157 | 56 | end
|
158 |
| - |
159 |
| - if isfield(scatter_data,'ZData') |
160 |
| - if isempty(scatter_data.ZData) |
161 |
| - obj.data{scatterIndex}.showlegend = showleg; |
162 |
| - end |
| 57 | + |
| 58 | + if length(markerLineColor) == 1 |
| 59 | + obj.data{scatterIndex}.marker.line.color = markerLineColor{1} |
163 | 60 | end
|
164 | 61 |
|
165 |
| - %---------------------------------------------------------------------% |
166 |
| - |
167 |
| - %-scatter marker-% |
168 |
| - childmarker = extractScatterMarker(scatter_data(n)); |
169 |
| - |
170 |
| - %---------------------------------------------------------------------% |
171 |
| - |
172 |
| - %-line color-% |
173 |
| - if length(scatter_data) > 1 |
174 |
| - obj.data{scatterIndex}.marker.line.color{m} = childmarker.line.color{1}; |
175 |
| - else |
176 |
| - if length(childmarker.line.color) > 3 |
177 |
| - obj.data{scatterIndex}.marker.line.color = childmarker.line.color; |
178 |
| - else |
179 |
| - obj.data{scatterIndex}.marker.line.color = childmarker.line.color{1}; |
| 62 | + %-------------------------------------------------------------------------% |
| 63 | + |
| 64 | + %-set showlegend property-% |
| 65 | + if isScatter3D |
| 66 | + leg = get(scatterData.Annotation); |
| 67 | + legInfo = get(leg.LegendInformation); |
| 68 | + |
| 69 | + switch legInfo.IconDisplayStyle |
| 70 | + case 'on' |
| 71 | + showleg = true; |
| 72 | + case 'off' |
| 73 | + showleg = false; |
180 | 74 | end
|
| 75 | + |
| 76 | + obj.data{scatterIndex}.showlegend = showleg; |
181 | 77 | end
|
182 |
| - |
183 |
| - %---------------------------------------------------------------------% |
184 |
| - |
185 |
| - %-marker color-% |
186 |
| - if length(scatter_data) > 1 |
187 |
| - obj.data{scatterIndex}.marker.color{m} = childmarker.color{1}; |
188 |
| - else |
189 |
| - obj.data{scatterIndex}.marker.color = childmarker.color; |
190 |
| - end |
191 |
| - |
192 |
| - %---------------------------------------------------------------------% |
193 |
| - |
194 |
| - %-sizeref-% |
195 |
| - obj.data{scatterIndex}.marker.sizeref = childmarker.sizeref; |
196 |
| - |
197 |
| - %---------------------------------------------------------------------% |
198 |
| - |
199 |
| - %-sizemode-% |
200 |
| - obj.data{scatterIndex}.marker.sizemode = childmarker.sizemode; |
201 |
| - |
202 |
| - %---------------------------------------------------------------------% |
203 |
| - |
204 |
| - %-symbol-% |
205 |
| - if length(scatter_data) > 1 |
206 |
| - obj.data{scatterIndex}.marker.symbol{m} = childmarker.symbol; |
207 |
| - else |
208 |
| - obj.data{scatterIndex}.marker.symbol = childmarker.symbol; |
209 |
| - end |
210 |
| - |
211 |
| - %---------------------------------------------------------------------% |
212 |
| - |
213 |
| - %-size-% |
214 |
| - if length(scatter_data) > 1 |
215 |
| - obj.data{scatterIndex}.marker.size = childmarker.size; |
216 |
| - else |
217 |
| - obj.data{scatterIndex}.marker.size = childmarker.size * 0.15; |
218 |
| - end |
219 |
| - |
220 |
| - %---------------------------------------------------------------------% |
221 |
| - |
222 |
| - %-line width-% |
223 |
| - |
224 |
| - if length(scatter_data) > 1 || ischar(childmarker.line.color) |
225 |
| - obj.data{scatterIndex}.marker.line.width(m) = childmarker.line.width; |
226 |
| - else |
227 |
| - obj.data{scatterIndex}.marker.line.width = childmarker.line.width; |
228 |
| - % obj.data{scatterIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width; |
229 |
| - end |
230 |
| - |
231 |
| - %---------------------------------------------------------------------% |
232 |
| - |
233 |
| -end |
| 78 | + |
| 79 | + %-------------------------------------------------------------------------% |
234 | 80 | end
|
235 | 81 |
|
0 commit comments