Mercurial > hg > octave-nkf
comparison scripts/plot/axis.m @ 7376:b052b844e094
[project @ 2008-01-15 01:18:39 by jwe]
author | jwe |
---|---|
date | Tue, 15 Jan 2008 01:18:40 +0000 |
parents | 5389a52df87b |
children | 8ccd9b0bf6bc |
comparison
equal
deleted
inserted
replaced
7375:4fbfce35012a | 7376:b052b844e094 |
---|---|
158 set (ca, "ydir", "normal"); | 158 set (ca, "ydir", "normal"); |
159 | 159 |
160 ## aspect ratio | 160 ## aspect ratio |
161 elseif (strcmp (ax, "image")) | 161 elseif (strcmp (ax, "image")) |
162 set (ca, "dataaspectratio", [1, 1, 1]); | 162 set (ca, "dataaspectratio", [1, 1, 1]); |
163 ## FIXME should be the same as "tight" | 163 __do_tight_option__ (ca); |
164 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto"); | |
165 elseif (strcmp (ax, "equal") || strcmp (ax, "square")) | 164 elseif (strcmp (ax, "equal") || strcmp (ax, "square")) |
166 set (ca, "dataaspectratio", [1, 1, 1]); | 165 set (ca, "dataaspectratio", [1, 1, 1]); |
167 elseif (strcmp (ax, "normal")) | 166 elseif (strcmp (ax, "normal")) |
168 set (ca, "dataaspectratiomode", "auto"); | 167 set (ca, "dataaspectratiomode", "auto"); |
169 | 168 |
184 endif | 183 endif |
185 elseif (strcmp (ax, "manual")) | 184 elseif (strcmp (ax, "manual")) |
186 ## fixes the axis limits, like axis(axis) should; | 185 ## fixes the axis limits, like axis(axis) should; |
187 set (ca, "xlimmode", "manual", "ylimmode", "manual", "zlimmode", "manual"); | 186 set (ca, "xlimmode", "manual", "ylimmode", "manual", "zlimmode", "manual"); |
188 elseif (strcmp (ax, "tight")) | 187 elseif (strcmp (ax, "tight")) |
189 ## FIXME if tight, plot must set ranges to limits of the | 188 ## sets the axis limits to the min and max of all data. |
190 ## all the data on the current plot, even if from a previous call. | 189 __do_tight_option__ (ca); |
191 ## Instead, just let gnuplot do as it likes. | |
192 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto"); | |
193 | 190 |
194 ## tic marks | 191 ## tic marks |
195 elseif (strcmp (ax, "on") || strcmp (ax, "tic")) | 192 elseif (strcmp (ax, "on") || strcmp (ax, "tic")) |
196 set (ca, "xtickmode", "auto", "ytickmode", "auto", "ztickmode", "auto"); | 193 set (ca, "xtickmode", "auto", "ytickmode", "auto", "ztickmode", "auto"); |
197 set (ca, "xticklabelmode", "auto", "yticklabelmode", "auto", | 194 set (ca, "xticklabelmode", "auto", "yticklabelmode", "auto", |
270 | 267 |
271 else | 268 else |
272 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements"); | 269 error ("axis: expecting no args, or a vector with 2, 4, or 6 elements"); |
273 endif | 270 endif |
274 | 271 |
275 if (nargin > 2) | 272 if (! isempty (varargin)) |
276 __axis__ (ca, varargin{:}); | 273 __axis__ (ca, varargin{:}); |
277 endif | 274 endif |
278 | 275 |
279 endfunction | 276 endfunction |
277 | |
278 function lims = __get_tight_lims__ (ca, ax) | |
279 | |
280 ## Get the limits for axis ("tight"). | |
281 ## AX should be one of "x", "y", or "z". | |
282 kids = findobj (ca, "-property", [ax, "data"]); | |
283 if (isempty (kids)) | |
284 ## Return the current limits. | |
285 lims = get (ca, [ax, "lim"]); | |
286 else | |
287 data = get (kids, [ax, "data"]); | |
288 if (iscell (data)) | |
289 lims(1) = min (cellfun (@min, data)); | |
290 lims(2) = min (cellfun (@max, data)); | |
291 else | |
292 lims = [min(data), max(data)]; | |
293 end | |
294 end | |
295 | |
296 endfunction | |
297 | |
298 function __do_tight_option__ (ca) | |
299 | |
300 set (ca, | |
301 "xlim", __get_tight_lims__ (ca, "x"), | |
302 "ylim", __get_tight_lims__ (ca, "y"), | |
303 "zlim", __get_tight_lims__ (ca, "z")); | |
304 | |
305 endfunction | |
306 | |
280 | 307 |
281 %!demo | 308 %!demo |
282 %! t=0:0.01:2*pi; x=sin(t); | 309 %! t=0:0.01:2*pi; x=sin(t); |
283 %! | 310 %! |
284 %! subplot(221); title("normal plot"); | 311 %! subplot(221); title("normal plot"); |