1 ## Copyright (C) 1993-2012 John W. Eaton
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} bar (@var{x}, @var{y})
21 ## @deftypefnx {Function File} {} bar (@var{y})
22 ## @deftypefnx {Function File} {} bar (@var{x}, @var{y}, @var{w})
23 ## @deftypefnx {Function File} {} bar (@var{x}, @var{y}, @var{w}, @var{style})
24 ## @deftypefnx {Function File} {@var{h} =} bar (@dots{}, @var{prop}, @var{val})
25 ## @deftypefnx {Function File} {} bar (@var{h}, @dots{})
26 ## Produce a bar graph from two vectors of x-y data.
28 ## If only one argument is given, @var{y}, it is taken as a vector of y-values
29 ## and the x coordinates are taken to be the indices of the elements.
31 ## The default width of 0.8 for the bars can be changed using @var{w}.
33 ## If @var{y} is a matrix, then each column of @var{y} is taken to be a
34 ## separate bar graph plotted on the same graph. By default the columns
35 ## are plotted side-by-side. This behavior can be changed by the @var{style}
36 ## argument, which can take the values @code{"grouped"} (the default),
37 ## or @code{"stacked"}.
39 ## The optional return value @var{h} is a handle to the created "bar series"
40 ## object with one handle per column of the variable @var{y}. This
41 ## series allows common elements of the group of bar series objects to
42 ## be changed in a single bar series and the same properties are changed
43 ## in the other "bar series". For example,
47 ## h = bar (rand (5, 10));
48 ## set (h(1), "basevalue", 0.5);
53 ## changes the position on the base of all of the bar series.
55 ## The optional input handle @var{h} allows an axis handle to be passed.
57 ## The bar graph's appearance may be modified by specifying property/value
58 ## pairs. The following example modifies the face and edge colors.
61 ## bar (randn (1, 100), "facecolor", "r", "edgecolor", "b")
65 ## The color of the bars is taken from the figure's colormap, such that
69 ## bar (rand (10, 3));
70 ## colormap (summer (64));
75 ## will change the colors used for the bars. The color of bars can also be set
76 ## manually using the "facecolor" property as shown below.
80 ## h = bar (rand (10, 3));
81 ## set (h(1), "facecolor", "r")
82 ## set (h(2), "facecolor", "g")
83 ## set (h(3), "facecolor", "b")
87 ## @seealso{barh, plot}
92 function varargout = bar (varargin)
93 varargout = cell (nargout, 1);
94 [varargout{:}] = __bar__ (true, "bar", varargin{:});
98 %% FIXME: Need demo or test for function