|
82 | 82 |
|
83 | 83 | if isvector(zdata)
|
84 | 84 |
|
| 85 | + %---------------------------------------------------------------------% |
| 86 | + |
85 | 87 | %-contour type-%
|
86 | 88 | obj.data{contourIndex}.type = 'contour';
|
87 | 89 |
|
| 90 | + %---------------------------------------------------------------------% |
| 91 | + |
88 | 92 | %-contour x data-%
|
89 | 93 | if ~isvector(x)
|
90 | 94 | obj.data{contourIndex}.xdata = xdata(1,:);
|
91 | 95 | else
|
92 | 96 | obj.data{contourIndex}.xdata = xdata;
|
93 | 97 | end
|
94 |
| - |
| 98 | + |
| 99 | + %---------------------------------------------------------------------% |
| 100 | + |
95 | 101 | %-contour y data-%
|
96 | 102 | if ~isvector(y)
|
97 | 103 | obj.data{contourIndex}.ydata = ydata';
|
98 | 104 | else
|
99 | 105 | obj.data{contourIndex}.ydata = ydata';
|
100 | 106 | end
|
101 | 107 |
|
102 |
| - %-contour z data-% |
103 |
| - obj.data{contourIndex}.z = zdata; |
104 |
| - |
105 |
| -else |
106 |
| - |
107 |
| - %-contour type-% |
108 |
| - obj.data{contourIndex}.type = 'surface'; |
109 |
| - |
110 |
| - %-contour x and y data |
111 |
| - if isvector(xdata) |
112 |
| - [xdata, ydata] = meshgrid(xdata, ydata); |
113 |
| - end |
114 |
| - obj.data{contourIndex}.x = xdata; |
115 |
| - obj.data{contourIndex}.y = ydata; |
| 108 | + %---------------------------------------------------------------------% |
116 | 109 |
|
117 | 110 | %-contour z data-%
|
118 | 111 | obj.data{contourIndex}.z = zdata;
|
119 | 112 |
|
120 |
| - %-setting for contour lines z-direction-% |
121 |
| - if length(contour_data.LevelList) > 1 |
122 |
| - zstart = contour_data.LevelList(1); |
123 |
| - zend = contour_data.LevelList(end); |
124 |
| - zsize = mean(diff(contour_data.LevelList)); |
125 |
| - else |
126 |
| - zstart = contour_data.LevelList(1) - 1e-3; |
127 |
| - zend = contour_data.LevelList(end) + 1e-3; |
128 |
| - zsize = 2e-3; |
129 |
| - end |
130 |
| - l = 30; |
131 |
| - obj.data{contourIndex}.contours.z.start = zstart; |
132 |
| - obj.data{contourIndex}.contours.z.end = zend; |
133 |
| - obj.data{contourIndex}.contours.z.size = zsize; |
134 |
| - obj.data{contourIndex}.contours.z.show = true; |
135 |
| - obj.data{contourIndex}.contours.z.usecolormap = true; |
136 |
| - obj.data{contourIndex}.contours.z.width = contour_data.LineWidth; |
137 |
| - obj.data{contourIndex}.hidesurface = true; |
138 |
| - |
139 |
| -end |
140 |
| - |
141 |
| -%-------------------------------------------------------------------------% |
142 |
| - |
143 |
| -if isvector(zdata) |
| 113 | + %---------------------------------------------------------------------% |
144 | 114 |
|
145 | 115 | %-contour x type-%
|
146 | 116 |
|
147 | 117 | obj.data{contourIndex}.xtype = 'array';
|
148 | 118 |
|
149 |
| - %-------------------------------------------------------------------------% |
| 119 | + %---------------------------------------------------------------------% |
150 | 120 |
|
151 | 121 | %-contour y type-%
|
152 | 122 |
|
153 | 123 | obj.data{contourIndex}.ytype = 'array';
|
154 | 124 |
|
155 |
| -end |
156 |
| - |
157 |
| -%-------------------------------------------------------------------------% |
158 |
| - |
159 |
| -%-contour visible-% |
160 |
| - |
161 |
| -obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); |
162 |
| - |
163 |
| -%-------------------------------------------------------------------------% |
164 |
| - |
165 |
| -%-contour showscale-% |
166 |
| -obj.data{contourIndex}.showscale = false; |
167 |
| - |
168 |
| -%-------------------------------------------------------------------------% |
169 |
| - |
170 |
| -if isvector(zdata) |
| 125 | + %---------------------------------------------------------------------% |
| 126 | + |
171 | 127 | %-zauto-%
|
172 | 128 | obj.data{contourIndex}.zauto = false;
|
173 | 129 |
|
174 |
| - %-------------------------------------------------------------------------% |
| 130 | + %---------------------------------------------------------------------% |
175 | 131 |
|
176 | 132 | %-zmin-%
|
177 | 133 | obj.data{contourIndex}.zmin = axis_data.CLim(1);
|
178 | 134 |
|
179 |
| - %-------------------------------------------------------------------------% |
| 135 | + %---------------------------------------------------------------------% |
180 | 136 |
|
181 | 137 | %-zmax-%
|
182 | 138 | obj.data{contourIndex}.zmax = axis_data.CLim(2);
|
183 |
| -end |
184 |
| - |
185 |
| -%-------------------------------------------------------------------------% |
186 |
| - |
187 |
| -%-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% |
188 |
| -colormap = figure_data.Colormap; |
189 |
| - |
190 |
| -for c = 1:size((colormap),1) |
191 |
| - col = 255*(colormap(c,:)); |
192 |
| - obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; |
193 |
| -end |
194 |
| - |
195 |
| -%-------------------------------------------------------------------------% |
196 |
| - |
197 |
| -%-contour reverse scale-% |
198 |
| -obj.data{contourIndex}.reversescale = false; |
199 |
| - |
200 |
| -%-------------------------------------------------------------------------% |
201 |
| - |
202 |
| -if isvector(zdata) |
| 139 | + |
| 140 | + %---------------------------------------------------------------------% |
203 | 141 |
|
204 | 142 | %-autocontour-%
|
205 | 143 | obj.data{contourIndex}.autocontour = false;
|
206 | 144 |
|
207 |
| -end |
208 |
| - |
209 |
| -%-------------------------------------------------------------------------% |
210 |
| - |
211 |
| -if isvector(zdata) |
| 145 | + %---------------------------------------------------------------------% |
212 | 146 |
|
213 | 147 | %-contour contours-%
|
214 | 148 |
|
|
229 | 163 | %-step-%
|
230 | 164 | obj.data{contourIndex}.contours.size = diff(contour_data.TextList(1:2));
|
231 | 165 |
|
232 |
| -end |
233 |
| - |
234 |
| -%-------------------------------------------------------------------------% |
235 |
| - |
236 |
| -if isvector(zdata) |
| 166 | + %---------------------------------------------------------------------% |
| 167 | + |
| 168 | + %-contour line setting-% |
237 | 169 | if(~strcmp(contour_data.LineStyle,'none'))
|
238 | 170 |
|
239 | 171 | %-contour line colour-%
|
|
270 | 202 | obj.data{contourIndex}.contours.showlines = false;
|
271 | 203 |
|
272 | 204 | end
|
| 205 | + |
| 206 | + %---------------------------------------------------------------------% |
| 207 | + |
| 208 | +else |
| 209 | + |
| 210 | + %---------------------------------------------------------------------% |
| 211 | + |
| 212 | + %-contour type-% |
| 213 | + obj.data{contourIndex}.type = 'surface'; |
| 214 | + |
| 215 | + %---------------------------------------------------------------------% |
| 216 | + |
| 217 | + %-contour x and y data |
| 218 | + if isvector(xdata) |
| 219 | + [xdata, ydata] = meshgrid(xdata, ydata); |
| 220 | + end |
| 221 | + obj.data{contourIndex}.x = xdata; |
| 222 | + obj.data{contourIndex}.y = ydata; |
| 223 | + |
| 224 | + %---------------------------------------------------------------------% |
| 225 | + |
| 226 | + %-contour z data-% |
| 227 | + obj.data{contourIndex}.z = zdata; |
| 228 | + |
| 229 | + %---------------------------------------------------------------------% |
| 230 | + |
| 231 | + %-setting for contour lines z-direction-% |
| 232 | + if length(contour_data.LevelList) > 1 |
| 233 | + zstart = contour_data.LevelList(1); |
| 234 | + zend = contour_data.LevelList(end); |
| 235 | + zsize = mean(diff(contour_data.LevelList)); |
| 236 | + else |
| 237 | + zstart = contour_data.LevelList(1) - 1e-3; |
| 238 | + zend = contour_data.LevelList(end) + 1e-3; |
| 239 | + zsize = 2e-3; |
| 240 | + end |
| 241 | + |
| 242 | + obj.data{contourIndex}.contours.z.start = zstart; |
| 243 | + obj.data{contourIndex}.contours.z.end = zend; |
| 244 | + obj.data{contourIndex}.contours.z.size = zsize; |
| 245 | + obj.data{contourIndex}.contours.z.show = true; |
| 246 | + obj.data{contourIndex}.contours.z.usecolormap = true; |
| 247 | + obj.data{contourIndex}.contours.z.width = 2*contour_data.LineWidth; |
| 248 | + obj.data{contourIndex}.hidesurface = true; |
| 249 | + |
| 250 | + %---------------------------------------------------------------------% |
| 251 | + |
| 252 | + %-colorscale-% |
| 253 | + colormap = figure_data.Colormap; |
| 254 | + |
| 255 | + for c = 1:size((colormap),1) |
| 256 | + col = 255*(colormap(c,:)); |
| 257 | + obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; |
| 258 | + end |
| 259 | + |
| 260 | + %---------------------------------------------------------------------% |
| 261 | + |
| 262 | + %-aspect ratio-% |
| 263 | + ar = obj.PlotOptions.AspectRatio; |
| 264 | + |
| 265 | + if ~isempty(ar) |
| 266 | + if ischar(ar) |
| 267 | + obj.layout.scene.aspectmode = ar; |
| 268 | + elseif isvector(ar) && length(ar) == 3 |
| 269 | + xar = ar(1); |
| 270 | + yar = ar(2); |
| 271 | + zar = ar(3); |
| 272 | + end |
| 273 | + else |
| 274 | + |
| 275 | + %-define as default-% |
| 276 | + xar = max(xdata(:)); |
| 277 | + yar = max(ydata(:)); |
| 278 | + zar = 0.7*max([xar, yar]); |
| 279 | + end |
| 280 | + |
| 281 | + obj.layout.scene.aspectratio.x = xar; |
| 282 | + obj.layout.scene.aspectratio.y = yar; |
| 283 | + obj.layout.scene.aspectratio.z = zar; |
| 284 | + |
| 285 | + %---------------------------------------------------------------------% |
| 286 | + |
| 287 | + %-camera eye-% |
| 288 | + ey = obj.PlotOptions.CameraEye; |
| 289 | + |
| 290 | + if ~isempty(ey) |
| 291 | + if isvector(ey) && length(ey) == 3 |
| 292 | + obj.layout.scene.camera.eye.x = ey(1); |
| 293 | + obj.layout.scene.camera.eye.y = ey(2); |
| 294 | + obj.layout.scene.camera.eye.z = ey(3); |
| 295 | + end |
| 296 | + else |
| 297 | + |
| 298 | + %-define as default-% |
| 299 | + xey = min(xdata(:)); if xey>0 xfac = -0.2; else xfac = 0.2; end |
| 300 | + yey = min(ydata(:)); if yey>0 yfac = -0.2; else yfac = 0.2; end |
| 301 | + if zar>0 zfac = -0.15; else zfac = 0.15; end |
| 302 | + |
| 303 | + obj.layout.scene.camera.eye.x = xey + xfac*xey; |
| 304 | + obj.layout.scene.camera.eye.y = yey + yfac*yey; |
| 305 | + obj.layout.scene.camera.eye.z = zar + yfac*zar; |
| 306 | + end |
| 307 | + |
| 308 | + %---------------------------------------------------------------------% |
| 309 | + |
| 310 | + %-zerolines hidded-% |
| 311 | + obj.layout.scene.xaxis.zeroline = false; |
| 312 | + obj.layout.scene.yaxis.zeroline = false; |
| 313 | + obj.layout.scene.zaxis.zeroline = false; |
| 314 | + |
| 315 | + %---------------------------------------------------------------------% |
| 316 | + |
273 | 317 | end
|
274 | 318 |
|
275 | 319 | %-------------------------------------------------------------------------%
|
276 | 320 |
|
| 321 | +%-contour visible-% |
| 322 | +obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); |
| 323 | + |
| 324 | +%-------------------------------------------------------------------------% |
| 325 | + |
| 326 | +%-contour showscale-% |
| 327 | +obj.data{contourIndex}.showscale = false; |
| 328 | + |
| 329 | +%-------------------------------------------------------------------------% |
| 330 | + |
| 331 | +%-contour reverse scale-% |
| 332 | +obj.data{contourIndex}.reversescale = false; |
| 333 | + |
| 334 | +%-------------------------------------------------------------------------% |
| 335 | + |
277 | 336 | %-contour showlegend-%
|
278 | 337 |
|
279 | 338 | leg = get(contour_data.Annotation);
|
|
0 commit comments