|
91 | 91 | %-------------------------------------------------------------------------% |
92 | 92 |
|
93 | 93 | %-axis type-% |
94 | | - |
95 | 94 | axis.type = eval(['axis_data.' axisName 'Scale']); |
96 | 95 |
|
97 | 96 | %-------------------------------------------------------------------------% |
|
120 | 119 | %---------------------------------------------------------------------% |
121 | 120 |
|
122 | 121 | else |
| 122 | + |
| 123 | + %-get axis limits-% |
| 124 | + dataLim = eval( sprintf('axis_data.%sLim', axisName) ); |
123 | 125 |
|
124 | 126 | %-axis tick direction-% |
125 | 127 | switch axis_data.TickDir |
|
140 | 142 |
|
141 | 143 | %---------------------------------------------------------------------% |
142 | 144 |
|
| 145 | + %-LOG TYPE-% |
143 | 146 | if strcmp(axis.type,'log') |
144 | 147 |
|
145 | 148 | %-axis range-% |
146 | | - axis.range = eval(['log10(axis_data.' axisName 'Lim);']); |
| 149 | + axis.range = eval( sprintf('log10(dataLim)') ); %['log10(axis_data.' axisName 'Lim);']); |
147 | 150 | %-axis autotick-% |
148 | 151 | axis.autotick = true; |
149 | 152 | %-axis nticks-% |
150 | 153 | axis.nticks = eval(['length(axis_data.' axisName 'Tick) + 1;']); |
151 | 154 |
|
152 | 155 | %---------------------------------------------------------------------% |
153 | 156 |
|
| 157 | + %-LINEAR TYPE-% |
154 | 158 | elseif strcmp(axis.type,'linear') |
| 159 | + |
| 160 | + %-----------------------------------------------------------------% |
| 161 | + |
| 162 | + %-get tick label mode-% |
155 | 163 | TickLabelMode = eval(['axis_data.' axisName 'TickLabelMode;']); |
| 164 | + |
| 165 | + %-----------------------------------------------------------------% |
| 166 | + |
| 167 | + %-AUTO MODE-% |
156 | 168 | if strcmp(TickLabelMode,'auto') |
157 | 169 |
|
158 | | - %-axis range-% |
159 | | - dataLim = eval(['axis_data.' axisName 'Lim']); |
160 | | - |
161 | 170 | %-------------------------------------------------------------% |
162 | 171 |
|
163 | 172 | if isnumeric(dataLim) |
|
192 | 201 | axis.autotick = true; |
193 | 202 | %-axis numticks-% |
194 | 203 | axis.nticks = eval(['length(axis_data.' axisName 'Tick)+1']); |
| 204 | + |
195 | 205 | %-----------------------------------------------------------------% |
196 | 206 |
|
| 207 | + %-CUSTOM MODE-% |
197 | 208 | else |
198 | | - %-axis show tick labels-% |
199 | | - Tick = eval(['axis_data.' axisName 'TickLabel;']); |
200 | | - if isempty(Tick) |
| 209 | + |
| 210 | + %-------------------------------------------------------------% |
| 211 | + |
| 212 | + %-get tick labels-% |
| 213 | + tickLabels = eval(['axis_data.' axisName 'TickLabel;']); |
| 214 | + |
| 215 | + %-------------------------------------------------------------% |
| 216 | + |
| 217 | + %-hide tick labels as lichkLabels field is empty-% |
| 218 | + if isempty(tickLabels) |
| 219 | + |
| 220 | + %-------------------------------------------------------------% |
| 221 | + |
201 | 222 | %-hide tick labels-% |
202 | 223 | axis.showticklabels = false; |
| 224 | + |
| 225 | + %-------------------------------------------------------------% |
| 226 | + |
203 | 227 | %-axis autorange-% |
204 | 228 | axis.autorange = true; |
| 229 | + |
| 230 | + %-------------------------------------------------------------% |
| 231 | + |
| 232 | + %-axis show tick labels as tickLabels matlab field-% |
205 | 233 | else |
206 | | - %-axis labels |
207 | | - labels = str2double(axis_data.YTickLabel); |
208 | | - try |
209 | | - %find numbers in labels |
210 | | - labelnums = find(~isnan(labels)); |
211 | | - %-axis type linear-% |
212 | | - axis.type = 'linear'; |
213 | | - %-range (overwrite)-% |
214 | | - delta = (labels(labelnums(2)) - labels(labelnums(1)))/(labelnums(2)-labelnums(1)); |
215 | | - axis.range = [labels(labelnums(1))-delta*(labelnums(1)-1) labels(labelnums(1)) + (length(labels)-labelnums(1))*delta]; |
216 | | - %-axis autotick-% |
217 | | - axis.autotick = true; |
218 | | - %-axis numticks-% |
219 | | - axis.nticks = eval(['length(axis_data.' axisName 'Tick) + 1;']); |
220 | | - catch |
221 | | - %-axis type category-% |
222 | | - axis.type = 'category'; |
223 | | - %-range (overwrite)-% |
| 234 | + |
| 235 | + %-------------------------------------------------------------% |
| 236 | + |
| 237 | + axis.showticklabels = true; |
| 238 | + axis.type = 'linear'; |
| 239 | + |
| 240 | + %-------------------------------------------------------------% |
| 241 | + |
| 242 | + if isnumeric(dataLim) |
| 243 | + axis.range = eval(['axis_data.' axisName 'Lim;']); |
| 244 | + else |
224 | 245 | axis.autorange = true; |
225 | | - %-axis autotick-% |
226 | | - % axis.autotick = true; |
227 | 246 | end |
| 247 | + |
| 248 | + %-------------------------------------------------------------% |
| 249 | + |
| 250 | + axis.tickvals = tick; |
| 251 | + axis.ticktext = tickLabels; |
| 252 | + |
| 253 | + %-------------------------------------------------------------% |
| 254 | + |
| 255 | + %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% |
| 256 | + % NOTE: |
| 257 | + % The next piece of code was replaced by the previous one. |
| 258 | + % I think that the new piece of code is better, optimal and |
| 259 | + % extends to all cases. However, I will leave this piece of |
| 260 | + % code commented in case there is a problem in the future. |
| 261 | + % |
| 262 | + % If there is a problem with the new piece of code, please |
| 263 | + % comment and uncomment the next piece of code. |
| 264 | + % |
| 265 | + % If everything goes well with the new gripping piece, at |
| 266 | + % the end of the development we will be able to remove the |
| 267 | + % commented lines |
| 268 | + %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% |
| 269 | + |
| 270 | + %-axis labels |
| 271 | + % labels = str2double(tickLabels); |
| 272 | + % try |
| 273 | + % %find numbers in labels |
| 274 | + % labelnums = find(~isnan(labels)); |
| 275 | + % %-axis type linear-% |
| 276 | + % axis.type = 'linear'; |
| 277 | + % %-range (overwrite)-% |
| 278 | + % delta = (labels(labelnums(2)) - labels(labelnums(1)))/(labelnums(2)-labelnums(1)); |
| 279 | + % axis.range = [labels(labelnums(1))-delta*(labelnums(1)-1) labels(labelnums(1)) + (length(labels)-labelnums(1))*delta]; |
| 280 | + % %-axis autotick-% |
| 281 | + % axis.autotick = true; |
| 282 | + % %-axis numticks-% |
| 283 | + % axis.nticks = eval(['length(axis_data.' axisName 'Tick) + 1;']); |
| 284 | + % catch |
| 285 | + % %-axis type category-% |
| 286 | + % axis.type = 'category'; |
| 287 | + % %-range (overwrite)-% |
| 288 | + % axis.autorange = true; |
| 289 | + % %-axis autotick-% |
| 290 | + % % axis.autotick = true; |
| 291 | + % end |
228 | 292 | end |
229 | 293 | end |
230 | 294 | end |
|
0 commit comments