comparison scripts/plot/plot.m @ 17036:08dd9458684a

Overhaul __plt_get_axis_arg__ and newplot functions to avoid creating unnecessary axes. * scripts/plot/__plt_get_axis_arg__.m: Only return an axis handle if found in argument list. Do not create any figures or axes. * scripts/plot/newplot.m: Overhaul to allow specifying an axis handle input. Prepare figure and axes according to Matlab conventions. * scripts/plot/line.m: Never call newplot() for a core graphic object. Always plot into gca. * scripts/plot/plot.m: Update to use new __plt_get_axis_arg__ and newplot functions.
author Rik <rik@octave.org>
date Wed, 24 Jul 2013 23:05:37 -0700
parents fee211d42c5c
children eaab03308c0b
comparison
equal deleted inserted replaced
17035:08f0e372d006 17036:08dd9458684a
179 ## stairs, errorbar, xlabel, ylabel, title, print} 179 ## stairs, errorbar, xlabel, ylabel, title, print}
180 ## @end deftypefn 180 ## @end deftypefn
181 181
182 ## Author: jwe 182 ## Author: jwe
183 183
184 function retval = plot (varargin) 184 function h = plot (varargin)
185 185
186 [h, varargin, nargs] = __plt_get_axis_arg__ ("plot", varargin{:}); 186 [hax, varargin, nargs] = __plt_get_axis_arg__ ("plot", varargin{:});
187 187
188 if (nargs < 1) 188 if (nargs < 1)
189 print_usage (); 189 print_usage ();
190 endif 190 endif
191 191
192 oldh = gca (); 192 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
193 unwind_protect 193 unwind_protect
194 axes (h); 194 hax = newplot (hax);
195 newplot (); 195 htmp = __plt__ ("plot", hax, varargin{:});
196 tmp = __plt__ ("plot", h, varargin{:});
197 unwind_protect_cleanup 196 unwind_protect_cleanup
198 axes (oldh); 197 if (! isempty (oldfig))
198 set (0, "currentfigure", oldfig);
199 endif
199 end_unwind_protect 200 end_unwind_protect
200 201
201 if (nargout > 0) 202 if (nargout > 0)
202 retval = tmp; 203 h = htmp;
203 endif 204 endif
204 205
205 endfunction 206 endfunction
206 207
207 208