Mercurial > hg > octave-nkf
diff scripts/plot/ylabel.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/ylabel.m +++ b/scripts/plot/ylabel.m @@ -18,26 +18,41 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} ylabel (@var{string}) -## @deftypefnx {Function File} {} ylabel (@var{h}, @var{string}) +## @deftypefnx {Function File} {} ylabel (@var{string}, @var{property}, @var{val}, @dots{}) +## @deftypefnx {Function File} {} ylabel (@var{hax}, @var{string}) +## @deftypefnx {Function File} {} ylabel (@var{hax}, @var{string}, @var{property}, @var{val}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} ylabel (@dots{}) -## @seealso{xlabel} +## Specify the string used to label the y-axis of the current axis. +## +## If @var{hax} is specified then label the axis defined by @var{hax}. +## +## 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{xlabel, zlabel, title, text} ## @end deftypefn ## Author: jwe -function retval = ylabel (varargin) +function h = ylabel (varargin) + + [hax, varargin, nargin] = __plt_get_axis_arg__ ("ylabel", varargin{:}); - [h, varargin, nargin] = __plt_get_axis_arg__ ("ylabel", varargin{:}); - + if (isempty (hax)) + hax = gca (); + endif + if (rem (nargin, 2) != 1) print_usage (); endif - tmp = __axis_label__ (h, "ylabel", varargin{:}, - "color", get (h, "ycolor")); + htmp = __axis_label__ (hax, "ylabel", varargin{1}, + "color", get (hax, "ycolor"), varargin{2:end}); if (nargout > 0) - retval = tmp; + h = htmp; endif endfunction @@ -46,11 +61,12 @@ %!test %! hf = figure ("visible", "off"); %! unwind_protect -%! y = ylabel ("ylabel_string"); +%! y = ylabel ("ylabel_string", "color", "r"); %! assert (get (gca, "ylabel"), y); %! assert (get (y, "type"), "text"); %! assert (get (y, "visible"), "on"); %! assert (get (y, "string"), "ylabel_string"); +%! assert (get (y, "color"), [1 0 0]); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect