comparison scripts/plot/errorbar.m @ 17059:c935a0db31c6

errorbar.m: Update to use new __plt_get_axis_arg__. * scripts/plot/errorbar.m: Update to use new __plt_get_axis_arg__.
author Rik <rik@octave.org>
date Wed, 24 Jul 2013 23:12:46 -0700
parents 64e7bb01fce2
children eaab03308c0b
comparison
equal deleted inserted replaced
17058:95c6cada5067 17059:c935a0db31c6
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} errorbar (@var{args}) 20 ## @deftypefn {Function File} {} errorbar (@var{args})
21 ## @deftypefnx {Function File} {@var{h} =} errorbar (@var{args}) 21 ## @deftypefnx {Function File} {@var{h} =} errorbar (@var{args})
22 ## This function produces two-dimensional plots with errorbars. Many 22 ## Create a two-dimensional plot with errorbars.
23 ## different combinations of arguments are possible. The simplest form is 23 ##
24 ## Many different combinations of arguments are possible. The simplest
25 ## form is
24 ## 26 ##
25 ## @example 27 ## @example
26 ## errorbar (@var{y}, @var{ey}) 28 ## errorbar (@var{y}, @var{ey})
27 ## @end example 29 ## @end example
28 ## 30 ##
115 117
116 ## Created: 18.7.2000 118 ## Created: 18.7.2000
117 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> 119 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
118 ## Keywords: errorbar, plotting 120 ## Keywords: errorbar, plotting
119 121
120 function retval = errorbar (varargin) 122 function h = errorbar (varargin)
121 123
122 [h, varargin] = __plt_get_axis_arg__ ("errorbar", varargin{:}); 124 [hax, varargin] = __plt_get_axis_arg__ ("errorbar", varargin{:});
123 125
124 oldh = gca (); 126 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
125 unwind_protect 127 unwind_protect
126 axes (h); 128 hax = newplot (hax);
127 newplot ();
128 129
129 tmp = __errcomm__ ("errorbar", h, varargin{:}); 130 htmp = __errcomm__ ("errorbar", hax, varargin{:});
130 131
131 if (nargout > 0) 132 unwind_protect_cleanup
132 retval = tmp; 133 if (! isempty (oldfig))
134 set (0, "currentfigure", oldfig);
133 endif 135 endif
134 unwind_protect_cleanup
135 axes (oldh);
136 end_unwind_protect 136 end_unwind_protect
137
138 if (nargout > 0)
139 h = htmp;
140 endif
137 141
138 endfunction 142 endfunction
139 143
140 144
141 %!demo 145 %!demo
151 %! errorbar (0:10, rand_1x11_data3, rand_1x11_data4, '>'); 155 %! errorbar (0:10, rand_1x11_data3, rand_1x11_data4, '>');
152 156
153 %!demo 157 %!demo
154 %! clf; 158 %! clf;
155 %! x = 0:0.5:2*pi; 159 %! x = 0:0.5:2*pi;
156 %! err = x/100; 160 %! err = x/30;
157 %! y1 = sin (x); 161 %! y1 = sin (x);
158 %! y2 = cos (x); 162 %! y2 = cos (x);
159 %! hg = errorbar (x, y1, err, '~', x, y2, err, '>'); 163 %! hg = errorbar (x, y1, err, '~', x, y2, err, '>');
160 164
161 %!demo 165 %!demo
162 %! clf; 166 %! clf;
163 %! x = 0:0.5:2*pi; 167 %! x = 0:0.5:2*pi;
164 %! err = x/100; 168 %! err = x/30;
165 %! y1 = sin (x); 169 %! y1 = sin (x);
166 %! y2 = cos (x); 170 %! y2 = cos (x);
167 %! hg = errorbar (x, y1, err, err, '#r', x, y2, err, err, '#~'); 171 %! hg = errorbar (x, y1, err, err, '#r', x, y2, err, err, '#~');
168 172
169 %!demo 173 %!demo
170 %! clf; 174 %! clf;
171 %! x = 0:0.5:2*pi; 175 %! x = 0:0.5:2*pi;
172 %! err = x/100; 176 %! err = x/30;
173 %! y1 = sin (x); 177 %! y1 = sin (x);
174 %! y2 = cos (x); 178 %! y2 = cos (x);
175 %! hg = errorbar (x, y1, err, err, err, err, '~>', ... 179 %! hg = errorbar (x, y1, err, err, err, err, '~>', ...
176 %! x, y2, err, err, err, err, '#~>-*'); 180 %! x, y2, err, err, err, err, '#~>-*');
177 181