|
42 | 42 | % position:...[NOT SUPPORTED IN MATLAB]
|
43 | 43 |
|
44 | 44 | %-STANDARDIZE UNITS-%
|
45 |
| -axisunits = get(obj.State.Axis(axIndex).Handle,'Units'); |
| 45 | +axisUnits = get(obj.State.Axis(axIndex).Handle,'Units'); |
46 | 46 | set(obj.State.Axis(axIndex).Handle,'Units','normalized')
|
47 | 47 |
|
48 | 48 | try
|
49 |
| - fontunits = get(obj.State.Axis(axIndex).Handle,'FontUnits'); |
| 49 | + fontUnits = get(obj.State.Axis(axIndex).Handle,'FontUnits'); |
50 | 50 | set(obj.State.Axis(axIndex).Handle,'FontUnits','points')
|
51 | 51 | catch
|
52 | 52 | % TODO
|
53 | 53 | end
|
54 | 54 |
|
55 | 55 | %-AXIS DATA STRUCTURE-%
|
56 |
| -axis_data = get(obj.State.Axis(axIndex).Handle); |
| 56 | +axisData = get(obj.State.Axis(axIndex).Handle); |
57 | 57 |
|
58 | 58 | %-------------------------------------------------------------------------%
|
59 | 59 |
|
60 | 60 | %-check if headmap axis-%
|
61 |
| -is_headmap_axis = isfield(axis_data, 'XDisplayData'); |
| 61 | +is_headmap_axis = isfield(axisData, 'XDisplayData'); |
62 | 62 | obj.PlotOptions.is_headmap_axis = is_headmap_axis;
|
63 | 63 |
|
64 | 64 | %-------------------------------------------------------------------------%
|
65 | 65 |
|
66 | 66 | %-check if geo-axis-%
|
67 |
| -isGeoaxis = isfield(axis_data, 'Type') && strcmpi(axis_data.Type, 'geoaxes'); |
| 67 | +isGeoaxis = isfield(axisData, 'Type') && strcmpi(axisData.Type, 'geoaxes'); |
68 | 68 | obj.PlotlyDefaults.isGeoaxis = isGeoaxis;
|
69 | 69 |
|
70 | 70 | %-------------------------------------------------------------------------%
|
71 | 71 |
|
72 | 72 | %-xaxis-%
|
73 | 73 | if is_headmap_axis
|
74 |
| - xaxis = extractHeatmapAxisData(obj,axis_data, 'X'); |
| 74 | + xaxis = extractHeatmapAxisData(obj,axisData, 'X'); |
| 75 | + xExponentFormat = 0; |
75 | 76 | else
|
76 |
| - xaxis = extractAxisData(obj,axis_data, 'X'); |
| 77 | + [xaxis, xExponentFormat] = extractAxisData(obj,axisData, 'X'); |
77 | 78 | end
|
78 | 79 |
|
79 | 80 | %-------------------------------------------------------------------------%
|
80 | 81 |
|
81 | 82 | %-yaxis-%
|
82 | 83 | if is_headmap_axis
|
83 |
| - yaxis = extractHeatmapAxisData(obj,axis_data, 'Y'); |
| 84 | + yaxis = extractHeatmapAxisData(obj,axisData, 'Y'); |
| 85 | + yExponentFormat = 0; |
84 | 86 | else
|
85 |
| - yaxis = extractAxisData(obj,axis_data, 'Y'); |
| 87 | + [yaxis, yExponentFormat] = extractAxisData(obj,axisData, 'Y'); |
86 | 88 | end
|
87 | 89 |
|
88 | 90 | %-------------------------------------------------------------------------%
|
89 | 91 |
|
90 | 92 | %-getting and setting postion data-%
|
91 |
| - |
92 |
| -xo = axis_data.Position(1); |
93 |
| -yo = axis_data.Position(2); |
94 |
| -w = axis_data.Position(3); |
95 |
| -h = axis_data.Position(4); |
| 93 | +xo = axisData.Position(1); |
| 94 | +yo = axisData.Position(2); |
| 95 | +w = axisData.Position(3); |
| 96 | +h = axisData.Position(4); |
96 | 97 |
|
97 | 98 | if obj.PlotOptions.AxisEqual
|
98 |
| - wh = min(axis_data.Position(3:4)); |
| 99 | + wh = min(axisData.Position(3:4)); |
99 | 100 | w = wh;
|
100 | 101 | h = wh;
|
101 | 102 | end
|
|
114 | 115 |
|
115 | 116 | %-------------------------------------------------------------------------%
|
116 | 117 |
|
| 118 | +%-get source axis-% |
117 | 119 | [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj,axIndex);
|
118 | 120 |
|
119 | 121 | %-------------------------------------------------------------------------%
|
120 | 122 |
|
| 123 | +%-set exponent format-% |
| 124 | +anIndex = obj.State.Figure.NumTexts; |
| 125 | + |
| 126 | +if yExponentFormat ~= 0 |
| 127 | + anIndex = anIndex + 1; |
| 128 | + exponentText = sprintf('x10^%d', yExponentFormat); |
| 129 | + |
| 130 | + obj.layout.annotations{anIndex}.text = exponentText; |
| 131 | + obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; |
| 132 | + obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; |
| 133 | + obj.layout.annotations{anIndex}.xanchor = 'left'; |
| 134 | + obj.layout.annotations{anIndex}.yanchor = 'bottom'; |
| 135 | + obj.layout.annotations{anIndex}.font.size = yaxis.tickfont.size; |
| 136 | + obj.layout.annotations{anIndex}.font.color = yaxis.tickfont.color; |
| 137 | + obj.layout.annotations{anIndex}.font.family = yaxis.tickfont.family; |
| 138 | + obj.layout.annotations{anIndex}.showarrow = false; |
| 139 | + |
| 140 | + if isfield(xaxis, 'range') && isfield(yaxis, 'range') |
| 141 | + obj.layout.annotations{anIndex}.x = min(xaxis.range); |
| 142 | + obj.layout.annotations{anIndex}.y = max(yaxis.range); |
| 143 | + end |
| 144 | +end |
| 145 | + |
| 146 | +if xExponentFormat ~= 0 |
| 147 | + anIndex = anIndex + 1; |
| 148 | + exponentText = sprintf('x10^%d', xExponentFormat); |
| 149 | + |
| 150 | + obj.layout.annotations{anIndex}.text = exponentText; |
| 151 | + obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; |
| 152 | + obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; |
| 153 | + obj.layout.annotations{anIndex}.xanchor = 'left'; |
| 154 | + obj.layout.annotations{anIndex}.yanchor = 'bottom'; |
| 155 | + obj.layout.annotations{anIndex}.font.size = xaxis.tickfont.size; |
| 156 | + obj.layout.annotations{anIndex}.font.color = xaxis.tickfont.color; |
| 157 | + obj.layout.annotations{anIndex}.font.family = xaxis.tickfont.family; |
| 158 | + obj.layout.annotations{anIndex}.showarrow = false; |
| 159 | + |
| 160 | + if isfield(xaxis, 'range') && isfield(yaxis, 'range') |
| 161 | + obj.layout.annotations{anIndex}.x = max(xaxis.range); |
| 162 | + obj.layout.annotations{anIndex}.y = min(yaxis.range); |
| 163 | + end |
| 164 | +end |
| 165 | + |
| 166 | +%-------------------------------------------------------------------------% |
| 167 | + |
121 | 168 | %-xaxis anchor-%
|
122 | 169 | xaxis.anchor = ['y' num2str(ysource)];
|
123 | 170 |
|
|
145 | 192 | % update the layout field (do not overwrite source)
|
146 | 193 | if xsource == axIndex
|
147 | 194 | obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis);
|
148 |
| - obj.layout = setfield(obj.layout,['scene' num2str(xsource)],scene); |
149 |
| -else |
150 |
| - |
| 195 | + obj.layout = setfield(obj.layout,['scene' num2str(xsource)],scene); |
151 | 196 | end
|
152 | 197 |
|
153 | 198 | %-------------------------------------------------------------------------%
|
154 | 199 |
|
155 | 200 | % update the layout field (do not overwrite source)
|
156 | 201 | if ysource == axIndex
|
157 | 202 | obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis);
|
158 |
| -else |
159 |
| - |
160 | 203 | end
|
161 | 204 |
|
162 | 205 | %-------------------------------------------------------------------------%
|
163 | 206 |
|
164 | 207 | %-REVERT UNITS-%
|
165 |
| -set(obj.State.Axis(axIndex).Handle,'Units',axisunits); |
| 208 | +set(obj.State.Axis(axIndex).Handle,'Units',axisUnits); |
166 | 209 |
|
167 | 210 | try
|
168 |
| - set(obj.State.Axis(axIndex).Handle,'FontUnits',fontunits); |
| 211 | + set(obj.State.Axis(axIndex).Handle,'FontUnits',fontUnits); |
169 | 212 | catch
|
170 | 213 | % TODO
|
171 | 214 | end
|
0 commit comments