Mercurial > hg > octave-lyh
diff scripts/plot/xlabel.m @ 17048:3f99d7d22bd0
x(yz)label.m, title.m: Update to use new __plt_get_axis_arg__.
* scripts/plot/title.m: Update to use new __plt_get_axis_arg__.
Rename h to hax. Redo docstring.
* scripts/plot/xlabel.m, scripts/plot/ylabel.m, scripts/plot/zlabel.m:
Update to use new __plt_get_axis_arg__. Rename h to hax. Redo docstrings
so that ylabel and zlabel have their own rather than pointing to xlabel.
Add check for using prop/val pairs to %!test block. Fix passing color argument
so that user prop/value overrides default.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Tue, 23 Jul 2013 14:31:58 +0200 |
parents | 72c96de7a403 |
children | eaab03308c0b |
line wrap: on
line diff
--- a/scripts/plot/xlabel.m +++ b/scripts/plot/xlabel.m @@ -18,32 +18,41 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} xlabel (@var{string}) -## @deftypefnx {Function File} {} xlabel (@var{h}, @var{string}) +## @deftypefnx {Function File} {} xlabel (@var{string}, @var{property}, @var{val}, @dots{}) +## @deftypefnx {Function File} {} xlabel (@var{hax}, @var{string}) +## @deftypefnx {Function File} {} xlabel (@var{hax}, @var{string}, @var{property}, @var{val}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} xlabel (@dots{}) -## @deftypefnx {Function File} {} ylabel (@dots{}) -## @deftypefnx {Function File} {} zlabel (@dots{}) -## Specify x-, y-, or z-axis labels for the current axis. If @var{h} is -## specified then label the axis defined by @var{h}. +## Specify the string used to label the x-axis of the current axis. +## +## If @var{hax} is specified then label the axis defined by @var{hax}. ## -## The optional return value @var{h} is a graphics handle to the created object. -## @seealso{title, text} +## An optional list of @var{property}/@var{value} pairs can be used to change +## the properties of the created text label. +## +## The optional return value @var{h} is a graphics handle to the created text +## object. +## @seealso{ylabel, zlabel, title, text} ## @end deftypefn ## Author: jwe -function retval = xlabel (varargin) +function h = xlabel (varargin) + + [hax, varargin, nargin] = __plt_get_axis_arg__ ("xlabel", varargin{:}); - [h, varargin, nargin] = __plt_get_axis_arg__ ("xlabel", varargin{:}); - + if (isempty (hax)) + hax = gca (); + endif + if (rem (nargin, 2) != 1) print_usage (); endif - tmp = __axis_label__ (h, "xlabel", varargin{:}, - "color", get (h, "xcolor")); + htmp = __axis_label__ (hax, "xlabel", varargin{1}, + "color", get (hax, "xcolor"), varargin{2:end}); if (nargout > 0) - retval = tmp; + h = htmp; endif endfunction @@ -52,11 +61,12 @@ %!test %! hf = figure ("visible", "off"); %! unwind_protect -%! x = xlabel ("xlabel_string"); +%! x = xlabel ("xlabel_string", "color", "r"); %! assert (get (gca, "xlabel"), x); %! assert (get (x, "type"), "text"); %! assert (get (x, "visible"), "on"); %! assert (get (x, "string"), "xlabel_string"); +%! assert (get (x, "color"), [1 0 0]); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect