changelog shortlog tags changeset files revisions annotate raw

scripts/plot/stem.m

changeset 10289: 4b124317dc38
parent:dbd0c77e575e
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (63 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 2006, 2007, 2008, 2009 Michel D. Schmid
2##
3## This file is part of Octave.
4##
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.
9##
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.
14##
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/>.
18
19## -*- texinfo -*-
20## @deftypefn {Function File} {@var{h} =} stem (@var{x}, @var{y}, @var{linespec})
21## @deftypefnx {Function File} {@var{h} =} stem (@dots{}, "filled")
22## Plot a stem graph from two vectors of x-y data. If only one argument
23## is given, it is taken as the y-values and the x coordinates are taken
24## from the indices of the elements.
25##
26## If @var{y} is a matrix, then each column of the matrix is plotted as
27## a separate stem graph. In this case @var{x} can either be a vector,
28## the same length as the number of rows in @var{y}, or it can be a
29## matrix of the same size as @var{y}.
30##
31## The default color is @code{"r"} (red). The default line style is
32## @code{"-"} and the default marker is @code{"o"}. The line style can
33## be altered by the @code{linespec} argument in the same manner as the
34## @code{plot} command. For example
35##
36## @example
37## @group
38## x = 1:10;
39## y = ones (1, length (x))*2.*x;
40## stem (x, y, "b");
41## @end group
42## @end example
43##
44## @noindent
45## plots 10 stems with heights from 2 to 20 in blue;
46##
47## The return value of @code{stem} is a vector if "stem series" graphics
48## handles, with one handle per column of the variable @var{y}. This
49## handle regroups the elements of the stem graph together as the
50## children of the "stem series" handle, allowing them to be altered
51## together. For example
52##
53## @example
54## @group
55## x = [0 : 10].';
56## y = [sin(x), cos(x)]
57## h = stem (x, y);
58## set (h(2), "color", "g");
59## set (h(1), "basevalue", -1)
60## @end group
61## @end example
62##
63## @noindent
64## changes the color of the second "stem series" and moves the base line
65## of the first.
66## @seealso{bar, barh, plot}
67## @end deftypefn
68
69## Author: Michel D. Schmid <michaelschmid@users.sourceforge.net>
70## Adapted-by: jwe
71
72function h = stem (varargin)
73
74 if (nargin < 1)
75 print_usage ();
76 endif
77
78 tmp = __stem__ (false, varargin{:});
79
80 if (nargout > 0)
81 h = tmp;
82 endif
83
84endfunction
85
86%!demo
87%! x = 1:10;
88%! stem (x);
89
90%!demo
91%! x = 1:10;
92%! y = ones (1, length (x))*2.*x;
93%! stem (x, y);
94
95%!demo
96%! x = 1:10;
97%! y = ones (size (x))*2.*x;
98%! h = stem (x, y, "b");
99
100%!demo
101%! x = 1:10;
102%! y = ones (size (x))*2.*x;
103%! h = stem (x, y, "-.k");
104
105%!demo
106%! x = 1:10;
107%! y = ones (size (x))*2.*x;
108%! h = stem (x, y, "-.k.");
109
110%!demo
111%! x = 1:10;
112%! y = ones (size (x))*2.*x;
113%! h = stem (x, y, "fill");
114
115%!demo
116%! x = [0 : 10].';
117%! y = [sin(x), cos(x)];
118%! h = stem (x, y);
119%! set (h(2), "color", "g");
120%! set (h(1), "basevalue", -1)