|
1 |
| -function obj = updateFunctionContour(obj,contourIndex) |
| 1 | +function data = updateFunctionContour(obj,contourIndex) |
2 | 2 | %-FIGURE DATA STRUCTURE-%
|
3 | 3 | figure_data = obj.State.Figure.Handle;
|
4 | 4 |
|
5 |
| - %-AXIS INDEX-% |
6 | 5 | axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis);
|
7 |
| - |
8 |
| - %-AXIS DATA STRUCTURE-% |
9 | 6 | axis_data = obj.State.Plot(contourIndex).AssociatedAxis;
|
10 |
| - |
11 |
| - %-PLOT DATA STRUCTURE- % |
12 | 7 | contour_data = obj.State.Plot(contourIndex).Handle;
|
13 |
| - |
14 |
| - %-CHECK FOR MULTIPLE AXES-% |
15 | 8 | [xsource, ysource] = findSourceAxis(obj,axIndex);
|
16 | 9 |
|
17 |
| - obj.data{contourIndex}.xaxis = "x" + xsource; |
18 |
| - obj.data{contourIndex}.yaxis = "y" + ysource; |
19 |
| - obj.data{contourIndex}.name = contour_data.DisplayName; |
20 |
| - obj.data{contourIndex}.type = 'contour'; |
| 10 | + data.xaxis = "x" + xsource; |
| 11 | + data.yaxis = "y" + ysource; |
| 12 | + data.name = contour_data.DisplayName; |
| 13 | + data.type = "contour"; |
21 | 14 |
|
22 |
| - %-setting the plot-% |
23 | 15 | xdata = contour_data.XData;
|
24 | 16 | ydata = contour_data.YData;
|
25 | 17 | zdata = contour_data.ZData;
|
26 | 18 |
|
27 |
| - %-contour x data-% |
28 | 19 | if ~isvector(xdata)
|
29 |
| - obj.data{contourIndex}.x = xdata(1,:); |
| 20 | + data.x = xdata(1,:); |
30 | 21 | else
|
31 |
| - obj.data{contourIndex}.x = xdata; |
| 22 | + data.x = xdata; |
32 | 23 | end
|
33 | 24 |
|
34 |
| - %-contour y data-% |
35 | 25 | if ~isvector(ydata)
|
36 |
| - obj.data{contourIndex}.y = ydata(:,1); |
| 26 | + data.y = ydata(:,1); |
37 | 27 | else
|
38 |
| - obj.data{contourIndex}.y = ydata; |
| 28 | + data.y = ydata; |
39 | 29 | end
|
40 | 30 |
|
41 |
| - %-contour z data-% |
42 |
| - obj.data{contourIndex}.z = zdata; |
| 31 | + data.z = zdata; |
43 | 32 |
|
44 |
| - obj.data{contourIndex}.xtype = 'array'; |
45 |
| - obj.data{contourIndex}.ytype = 'array'; |
46 |
| - obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); |
47 |
| - obj.data{contourIndex}.showscale = false; |
48 |
| - obj.data{contourIndex}.zauto = false; |
49 |
| - obj.data{contourIndex}.zmin = axis_data.CLim(1); |
50 |
| - obj.data{contourIndex}.zmax = axis_data.CLim(2); |
| 33 | + data.xtype = "array"; |
| 34 | + data.ytype = "array"; |
| 35 | + data.visible = contour_data.Visible == "on"; |
| 36 | + data.showscale = false; |
| 37 | + data.zauto = false; |
| 38 | + data.zmin = axis_data.CLim(1); |
| 39 | + data.zmax = axis_data.CLim(2); |
51 | 40 |
|
52 | 41 | %-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-%
|
53 | 42 | colormap = figure_data.Colormap;
|
54 | 43 |
|
55 | 44 | for c = 1:size((colormap),1)
|
56 | 45 | col = round(255*(colormap(c,:)));
|
57 |
| - obj.data{contourIndex}.colorscale{c} = ... |
58 |
| - {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; |
| 46 | + data.colorscale{c} = ... |
| 47 | + {(c-1)/(size(colormap,1)-1), getStringColor(col)}; |
59 | 48 | end
|
60 | 49 |
|
61 |
| - obj.data{contourIndex}.reversescale = false; |
62 |
| - obj.data{contourIndex}.autocontour = false; |
| 50 | + data.reversescale = false; |
| 51 | + data.autocontour = false; |
63 | 52 |
|
64 |
| - %-contour contours-% |
65 |
| - |
66 |
| - %-coloring-% |
67 | 53 | switch contour_data.Fill
|
68 |
| - case 'off' |
69 |
| - obj.data{contourIndex}.contours.coloring = 'lines'; |
70 |
| - case 'on' |
71 |
| - obj.data{contourIndex}.contours.coloring = 'fill'; |
| 54 | + case "off" |
| 55 | + data.contours.coloring = "lines"; |
| 56 | + case "on" |
| 57 | + data.contours.coloring = "fill"; |
72 | 58 | end
|
73 | 59 |
|
74 |
| - %-contour levels-% |
75 | 60 | if length(contour_data.LevelList) > 1
|
76 | 61 | cstart = contour_data.LevelList(1);
|
77 | 62 | cend = contour_data.LevelList(end);
|
|
82 | 67 | csize = 2e-3;
|
83 | 68 | end
|
84 | 69 |
|
85 |
| - %-start-% |
86 |
| - obj.data{contourIndex}.contours.start = cstart; |
87 |
| - %-end-% |
88 |
| - obj.data{contourIndex}.contours.end = cend; |
89 |
| - %-step-% |
90 |
| - obj.data{contourIndex}.contours.size = csize; |
| 70 | + data.contours.start = cstart; |
| 71 | + data.contours.end = cend; |
| 72 | + data.contours.size = csize; |
91 | 73 |
|
92 |
| - if (~strcmp(contour_data.LineStyle,'none')) |
93 |
| - %-contour line colour-% |
| 74 | + if contour_data.LineStyle ~= "none" |
94 | 75 | if isnumeric(contour_data.LineColor)
|
95 | 76 | col = round(255*contour_data.LineColor);
|
96 |
| - obj.data{contourIndex}.line.color = ... |
97 |
| - sprintf("rgb(%d,%d,%d)", col); |
| 77 | + data.line.color = getStringColor(col); |
98 | 78 | else
|
99 |
| - obj.data{contourIndex}.line.color = "rgba(0,0,0,0)"; |
| 79 | + data.line.color = "rgba(0,0,0,0)"; |
100 | 80 | end
|
101 | 81 |
|
102 |
| - %-contour line width-% |
103 |
| - obj.data{contourIndex}.line.width = contour_data.LineWidth; |
| 82 | + data.line.width = contour_data.LineWidth; |
104 | 83 |
|
105 |
| - %-contour line dash-% |
106 | 84 | switch contour_data.LineStyle
|
107 |
| - case '-' |
108 |
| - LineStyle = 'solid'; |
109 |
| - case '--' |
110 |
| - LineStyle = 'dash'; |
111 |
| - case ':' |
112 |
| - LineStyle = 'dot'; |
113 |
| - case '-.' |
114 |
| - LineStyle = 'dashdot'; |
| 85 | + case "-" |
| 86 | + LineStyle = "solid"; |
| 87 | + case "--" |
| 88 | + LineStyle = "dash"; |
| 89 | + case ":" |
| 90 | + LineStyle = "dot"; |
| 91 | + case "-." |
| 92 | + LineStyle = "dashdot"; |
115 | 93 | end
|
116 |
| - obj.data{contourIndex}.line.dash = LineStyle; |
117 |
| - obj.data{contourIndex}.line.smoothing = 0; |
| 94 | + data.line.dash = LineStyle; |
| 95 | + data.line.smoothing = 0; |
118 | 96 | else
|
119 |
| - obj.data{contourIndex}.contours.showlines = false; |
| 97 | + data.contours.showlines = false; |
120 | 98 | end
|
121 | 99 |
|
122 |
| - %-contour showlegend-% |
123 |
| - leg = contour_data.Annotation; |
124 |
| - legInfo = leg.LegendInformation; |
125 |
| - switch legInfo.IconDisplayStyle |
126 |
| - case 'on' |
127 |
| - showleg = true; |
128 |
| - case 'off' |
129 |
| - showleg = false; |
| 100 | + switch contour_data.Annotation.LegendInformation.IconDisplayStyle |
| 101 | + case "on" |
| 102 | + data.showlegend = true; |
| 103 | + case "off" |
| 104 | + data.showlegend = false; |
130 | 105 | end
|
131 |
| - obj.data{contourIndex}.showlegend = showleg; |
132 |
| - |
133 |
| - %-axis layout-% |
134 |
| - t = 'linear'; |
135 |
| - obj.layout.("xaxis" + xsource).type=t; |
136 |
| - obj.layout.("xaxis" + xsource).autorange=true; |
137 |
| - obj.layout.("xaxis" + xsource).ticktext=axis_data.XTickLabel; |
138 |
| - obj.layout.("xaxis" + xsource).tickvals=axis_data.XTick; |
139 |
| - |
140 |
| - obj.layout.("yaxis" + xsource).type=t; |
141 |
| - obj.layout.("yaxis" + xsource).autorange=true; |
142 |
| - obj.layout.("yaxis" + xsource).ticktext=axis_data.YTickLabel; |
143 |
| - obj.layout.("yaxis" + xsource).tickvals=axis_data.YTick; |
| 106 | + |
| 107 | + t = "linear"; |
| 108 | + obj.layout.("xaxis" + xsource).type = t; |
| 109 | + obj.layout.("xaxis" + xsource).autorange = true; |
| 110 | + obj.layout.("xaxis" + xsource).ticktext = axis_data.XTickLabel; |
| 111 | + obj.layout.("xaxis" + xsource).tickvals = axis_data.XTick; |
| 112 | + |
| 113 | + obj.layout.("yaxis" + xsource).type = t; |
| 114 | + obj.layout.("yaxis" + xsource).autorange = true; |
| 115 | + obj.layout.("yaxis" + xsource).ticktext = axis_data.YTickLabel; |
| 116 | + obj.layout.("yaxis" + xsource).tickvals = axis_data.YTick; |
144 | 117 | end
|
0 commit comments