Mercurial > hg > octave-nkf
diff scripts/plot/newplot.m @ 16076:c90c9623b20f
newplot.m: Return handle to created axes for Matlab compatibility (Bug #38146)
* newplot.m: Return handle to created axes if nargout > 0.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 20 Feb 2013 16:11:47 -0800 |
parents | f3d52523cde1 |
children | 08dd9458684a |
line wrap: on
line diff
--- a/scripts/plot/newplot.m +++ b/scripts/plot/newplot.m @@ -17,13 +17,17 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} newplot () +## @deftypefn {Function File} {} newplot () +## @deftypefnx {Function File} {@var{h} =} newplot () ## Prepare graphics engine to produce a new plot. This function is ## called at the beginning of all high-level plotting functions. ## It is not normally required in user programs. +## +## The optional return value @var{h} is a graphics handle to the created +## axes (not figure). ## @end deftypefn -function newplot () +function h = newplot () if (nargin == 0) cf = gcf (); @@ -59,6 +63,9 @@ otherwise error ("newplot: unrecognized nextplot property for current axes"); endswitch + if (nargout > 0) + h = ca; + endif else print_usage (); endif @@ -70,7 +77,8 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! p = plot ([0, 1]); -%! newplot; +%! ha = newplot (); +%! assert (ha, gca); %! assert (isempty (get (gca, "children"))); %! unwind_protect_cleanup %! close (hf);