Mercurial > hg > octave-nkf
comparison scripts/plot/axis.m @ 17045:6dec8dbf8a97
axis.m: Overhaul to use new __plt_get_axis_arg__.
* scripts/plot/axis.m: Use hax instead of h. Use gca if hax not set.
Rename output of function to match documentation.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:46 -0700 |
parents | be52288f827b |
children | eaab03308c0b |
comparison
equal
deleted
inserted
replaced
17044:cec8c423b3e8 | 17045:6dec8dbf8a97 |
---|---|
128 ## this axes rather than the current axes. | 128 ## this axes rather than the current axes. |
129 ## @end deftypefn | 129 ## @end deftypefn |
130 | 130 |
131 ## Author: jwe | 131 ## Author: jwe |
132 | 132 |
133 function varargout = axis (varargin) | 133 function limits = axis (varargin) |
134 | 134 |
135 [h, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); | 135 [hax, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); |
136 | 136 |
137 oldh = gca (); | 137 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); |
138 unwind_protect | 138 unwind_protect |
139 axes (h); | 139 if (isempty (hax)) |
140 varargout = cell (max (nargin == 0, nargout), 1); | 140 hax = gca (); |
141 if (isempty (varargout)) | 141 endif |
142 __axis__ (h, varargin{:}); | 142 if (nargin == 0) |
143 limits = __axis__ (hax, varargin{:}); | |
143 else | 144 else |
144 [varargout{:}] = __axis__ (h, varargin{:}); | 145 __axis__ (hax, varargin{:}); |
145 endif | 146 endif |
146 unwind_protect_cleanup | 147 unwind_protect_cleanup |
147 axes (oldh); | 148 if (! isempty (oldfig)) |
149 set (0, "currentfigure", oldfig); | |
150 endif | |
148 end_unwind_protect | 151 end_unwind_protect |
149 | 152 |
150 endfunction | 153 endfunction |
151 | 154 |
152 function curr_axis = __axis__ (ca, ax, varargin) | 155 function limits = __axis__ (ca, ax, varargin) |
153 | 156 |
154 if (nargin == 1) | 157 if (nargin == 1) |
155 if (nargout == 0) | 158 if (nargout == 0) |
156 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto"); | 159 set (ca, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto"); |
157 else | 160 else |
158 xlim = get (ca, "xlim"); | 161 xlim = get (ca, "xlim"); |
159 ylim = get (ca, "ylim"); | 162 ylim = get (ca, "ylim"); |
160 view = get (ca, "view"); | 163 view = get (ca, "view"); |
161 if (view(2) == 90) | 164 if (view(2) == 90) |
162 curr_axis = [xlim, ylim]; | 165 limits = [xlim, ylim]; |
163 else | 166 else |
164 zlim = get (ca, "zlim"); | 167 zlim = get (ca, "zlim"); |
165 curr_axis = [xlim, ylim, zlim]; | 168 limits = [xlim, ylim, zlim]; |
166 endif | 169 endif |
167 endif | 170 endif |
168 | 171 |
169 elseif (ischar (ax)) | 172 elseif (ischar (ax)) |
170 len = length (ax); | 173 len = length (ax); |
367 set (ca, "zlim", zlim); | 370 set (ca, "zlim", zlim); |
368 endif | 371 endif |
369 | 372 |
370 endfunction | 373 endfunction |
371 | 374 |
375 | |
372 %!demo | 376 %!demo |
373 %! clf; | 377 %! clf; |
374 %! t = 0:0.01:2*pi; | 378 %! t = 0:0.01:2*pi; |
375 %! x = sin (t); | 379 %! x = sin (t); |
376 %! | 380 %! |