view scripts/plot/appearance/xlabel.m @ 28733:9342688e86b4 stable

Updated property references for text and graphics functions (bug #50247) * /scripts/gui/dialog.m, waitbar.m: added Figure Properties reference * /scripts/gui/setappdata.m: added getappdata propery reference * /scripts/image/imagesc.m: added Image Properties reference * /scripts/image/imread.m: added Representing Images reference * /scripts/plot/appearance/clabel.m, gtext.m, xlabel.m, ylabel.m, zlabel.m: added Text Properties reference * /scripts/plot/appearance/legend.m: added Graphics Object Properties reference * /scripts/plot/appearance/private/__gnuplot_legend__.m: added Graphics Object Properties reference * /scripts/plot/draw/area.m, bar.m, barh.m, fill.m, hist.m, rectangle.m, scatter.m, scatter3.m, tetramesh.m, trimesh.m, trisurf.m: added Patch Properties reference * /scripts/plot/draw/colorbar.m: add Axes Properties reference * /scripts/plot/util/hggroup.m, subplot.m: added Axes Properties reference * /scripts/plot/draw/fplot.m, plot.m, plot3.m, stairs.m, stem.m, stem3.m: add/update Line Properties reference * /scripts/plot/draw/mesh.m, meshc.m, meshz.m, surf.m, surfc.m, surfnorm.m, waterfall.m: add/update Surface Properties reference * /doc/interpreter/plot.txi: removed redundant text properties link
author Nicholas R. Jankowski <jankowskin@asme.org>
date Tue, 18 Feb 2020 21:35:39 -0500
parents bd51beb6205e
children 0a5b15007766
line wrap: on
line source

########################################################################
##
## Copyright (C) 1993-2020 The Octave Project Developers
##
## See the file COPYRIGHT.md in the top-level directory of this
## distribution or <https://octave.org/copyright/>.
##
## This file is part of Octave.
##
## Octave is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <https://www.gnu.org/licenses/>.
##
########################################################################

## -*- texinfo -*-
## @deftypefn  {} {} xlabel (@var{string})
## @deftypefnx {} {} xlabel (@var{string}, @var{property}, @var{val}, @dots{})
## @deftypefnx {} {} xlabel (@var{hax}, @dots{})
## @deftypefnx {} {@var{h} =} xlabel (@dots{})
## Specify the string used to label the x-axis of the current axis.
##
## An optional list of @var{property}/@var{value} pairs can be used to change
## the properties of the created text label.
##
## The full list of text object properties is documented at
## @ref{Text Properties}.
##
## If the first argument @var{hax} is an axes handle, then operate on
## this axes rather than the current axes returned by @code{gca}.
##
## The optional return value @var{h} is a graphics handle to the created text
## object.
## @seealso{ylabel, zlabel, datetick, title, text}
## @end deftypefn

function h = xlabel (varargin)

  [hax, varargin, nargin] = __plt_get_axis_arg__ ("xlabel", varargin{:});

  if (isempty (hax))
    hax = gca ();
  endif

  if (rem (nargin, 2) != 1)
    print_usage ();
  endif

  htmp = __axis_label__ (hax, "xlabel", varargin{1},
                         "color", get (hax, "xcolor"),
                         varargin{2:end});

  if (nargout > 0)
    h = htmp;
  endif

endfunction


%!test
%! hf = figure ("visible", "off");
%! unwind_protect
%!   hx = xlabel ("xlabel_string");
%!   assert (get (gca, "xlabel"), hx);
%!   assert (get (hx, "type"), "text");
%!   assert (get (hx, "visible"), "on");
%!   assert (get (hx, "string"), "xlabel_string");
%!   assert (get (hx, "color"), get (0, "defaultaxesxcolor"));
%! unwind_protect_cleanup
%!   close (hf);
%! end_unwind_protect

%!test
%! hf = figure ("visible", "off");
%! unwind_protect
%!   set (gca, "fontsize", 5, "labelfontsizemultiplier", 3);
%!   hx = xlabel ("xlabel_string", "color", "r");
%!   assert (get (hx, "fontsize"), 15);
%!   assert (get (hx, "color"), [1 0 0]);
%! unwind_protect_cleanup
%!   close (hf);
%! end_unwind_protect