1########################################################################
2##
3## Copyright (C) 1996-2021 The Octave Project Developers
4##
5## See the file COPYRIGHT.md in the top-level directory of this
6## distribution or <https://octave.org/copyright/>.
7##
8## This file is part of Octave.
9##
10## Octave is free software: you can redistribute it and/or modify it
11## under the terms of the GNU General Public License as published by
12## the Free Software Foundation, either version 3 of the License, or
13## (at your option) any later version.
14##
15## Octave is distributed in the hope that it will be useful, but
16## WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18## GNU General Public License for more details.
19##
20## You should have received a copy of the GNU General Public License
21## along with Octave; see the file COPYING.  If not, see
22## <https://www.gnu.org/licenses/>.
23##
24########################################################################
25
26## -*- texinfo -*-
27## @deftypefn  {} {} barh (@var{y})
28## @deftypefnx {} {} barh (@var{x}, @var{y})
29## @deftypefnx {} {} barh (@dots{}, @var{w})
30## @deftypefnx {} {} barh (@dots{}, @var{style})
31## @deftypefnx {} {} barh (@dots{}, @var{prop}, @var{val}, @dots{})
32## @deftypefnx {} {} barh (@var{hax}, @dots{})
33## @deftypefnx {} {@var{h} =} barh (@dots{}, @var{prop}, @var{val}, @dots{})
34## Produce a horizontal bar graph from two vectors of X-Y data.
35##
36## If only one argument is given, it is taken as a vector of Y values
37## and the X coordinates are the range @code{1:numel (@var{y})}.
38##
39## The optional input @var{w} controls the width of the bars.  A value of
40## 1.0 will cause each bar to exactly touch any adjacent bars.
41## The default width is 0.8.
42##
43## If @var{y} is a matrix, then each column of @var{y} is taken to be a
44## separate bar graph plotted on the same graph.  By default the columns
45## are plotted side-by-side.  This behavior can be changed by the @var{style}
46## argument which can take the following values:
47##
48## @table @asis
49## @item @qcode{"grouped"} (default)
50## Side-by-side bars with a gap between bars and centered over the
51## Y-coordinate.
52##
53## @item  @qcode{"stacked"}
54## Bars are stacked so that each Y value has a single bar composed of
55## multiple segments.
56##
57## @item @qcode{"hist"}
58## Side-by-side bars with no gap between bars and centered over the
59## Y-coordinate.
60##
61## @item @qcode{"histc"}
62## Side-by-side bars with no gap between bars and left-aligned to the
63## Y-coordinate.
64## @end table
65##
66## Optional property/value pairs are passed directly to the underlying patch
67## objects.  The full list of properties is documented at
68## @ref{Patch Properties}.
69##
70## If the first argument @var{hax} is an axes handle, then plot into this axes,
71## rather than the current axes returned by @code{gca}.
72##
73## The optional return value @var{h} is a graphics handle to the created
74## bar series hggroup.  For a description of the use of the
75## bar series, @pxref{XREFbar,,bar}.
76## @seealso{bar, hist, pie, plot, patch}
77## @end deftypefn
78
79function varargout = barh (varargin)
80  varargout = cell (nargout, 1);
81  [varargout{:}] = __bar__ (false, "barh", varargin{:});
82endfunction
83
84
85%!demo
86%! clf;
87%! x = rand (10, 1);
88%! barh (x);
89%! title ("barh() graph");
90
91%!demo
92%! clf;
93%! h = barh (rand (5, 3));
94%! set (h(1), "facecolor", "r");
95%! set (h(2), "facecolor", "g");
96%! set (h(3), "facecolor", "b");
97%! title ("barh() graph w/multiple bars");
98