# HG changeset patch # User Rik # Date 1374732766 25200 # Node ID c935a0db31c6946f2c5259b36d0a20da536d1c98 # Parent 95c6cada50671db3ec4e0d1e19507294d32fd51a errorbar.m: Update to use new __plt_get_axis_arg__. * scripts/plot/errorbar.m: Update to use new __plt_get_axis_arg__. diff -r 95c6cada5067 -r c935a0db31c6 scripts/plot/errorbar.m --- a/scripts/plot/errorbar.m Wed Jul 24 23:12:46 2013 -0700 +++ b/scripts/plot/errorbar.m Wed Jul 24 23:12:46 2013 -0700 @@ -19,8 +19,10 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} errorbar (@var{args}) ## @deftypefnx {Function File} {@var{h} =} errorbar (@var{args}) -## This function produces two-dimensional plots with errorbars. Many -## different combinations of arguments are possible. The simplest form is +## Create a two-dimensional plot with errorbars. +## +## Many different combinations of arguments are possible. The simplest +## form is ## ## @example ## errorbar (@var{y}, @var{ey}) @@ -117,23 +119,25 @@ ## Author: Teemu Ikonen ## Keywords: errorbar, plotting -function retval = errorbar (varargin) +function h = errorbar (varargin) - [h, varargin] = __plt_get_axis_arg__ ("errorbar", varargin{:}); + [hax, varargin] = __plt_get_axis_arg__ ("errorbar", varargin{:}); - oldh = gca (); + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect - axes (h); - newplot (); + hax = newplot (hax); + + htmp = __errcomm__ ("errorbar", hax, varargin{:}); - tmp = __errcomm__ ("errorbar", h, varargin{:}); + unwind_protect_cleanup + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif + end_unwind_protect - if (nargout > 0) - retval = tmp; - endif - unwind_protect_cleanup - axes (oldh); - end_unwind_protect + if (nargout > 0) + h = htmp; + endif endfunction @@ -153,7 +157,7 @@ %!demo %! clf; %! x = 0:0.5:2*pi; -%! err = x/100; +%! err = x/30; %! y1 = sin (x); %! y2 = cos (x); %! hg = errorbar (x, y1, err, '~', x, y2, err, '>'); @@ -161,7 +165,7 @@ %!demo %! clf; %! x = 0:0.5:2*pi; -%! err = x/100; +%! err = x/30; %! y1 = sin (x); %! y2 = cos (x); %! hg = errorbar (x, y1, err, err, '#r', x, y2, err, err, '#~'); @@ -169,7 +173,7 @@ %!demo %! clf; %! x = 0:0.5:2*pi; -%! err = x/100; +%! err = x/30; %! y1 = sin (x); %! y2 = cos (x); %! hg = errorbar (x, y1, err, err, err, err, '~>', ...