annotate scripts/plot/private/__bar__.m @ 11202:1840a0ecf1fb

__bar__.m: Permit bar() to be called with scalar inputs.
author Ben Abbott <bpabbott@mac.com>
date Mon, 08 Nov 2010 08:59:52 +0800
parents 95c3e38098bf
children fd0a3ac60b0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
1 ## Copyright (C) 1996, 1997, 2007, 2008, 2009 John W. Eaton
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
2 ##
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
3 ## This file is part of Octave.
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
4 ##
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
9 ##
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
13 ## General Public License for more details.
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
14 ##
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8664
diff changeset
19 ## -*- texinfo -*-
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8664
diff changeset
20 ## @deftypefn {Function File} {} __bar__ (@var{vertical}, @var{func}, @dots{})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
21 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8664
diff changeset
22 ## @end deftypefn
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
23
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
24 ## Author: jwe
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
25
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
26 function varargout = __bar__ (vertical, func, varargin)
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
27
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
28 [h, varargin] = __plt_get_axis_arg__ ((nargout > 1), func, varargin{:});
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
29
7148
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7039
diff changeset
30 ## Slightly smaller than 0.8 to avoid clipping issue in gnuplot 4.0
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7039
diff changeset
31 width = 0.8 - 10 * eps;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
32 group = true;
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
33 bv = 0;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
34
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
35 if (nargin < 3)
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
36 print_usage ();
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
37 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
38
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
39 if (nargin > 3 && isnumeric (varargin{2}))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
40 x = varargin{1};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
41 if (isvector (x))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
42 x = x(:);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
43 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
44 y = varargin{2};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
45 if (isvector (y))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
46 y = y(:);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
47 endif
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
48 if (size (x, 1) != size (y, 1))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
49 y = varargin{1};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
50 if (isvector (y))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
51 y = y(:);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
52 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
53 x = [1:size(y,1)]';
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
54 idx = 2;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
55 else
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
56 if (! isvector (x))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
57 error ("%s: x must be a vector", func);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
58 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
59 idx = 3;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
60 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
61 else
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
62 y = varargin{1};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
63 if (isvector (y))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
64 y = y(:);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
65 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
66 x = [1:size(y,1)]';
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
67 idx = 2;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
68 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
69
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
70 newargs = {};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
71 have_line_spec = false;
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
72 while (idx <= nargin - 2)
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8056
diff changeset
73 if (ischar (varargin{idx}) && strcmpi (varargin{idx}, "grouped"))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
74 group = true;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
75 idx++;
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8056
diff changeset
76 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "stacked"))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
77 group = false;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
78 idx++;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
79 else
7768
a2d9f325b65a Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents: 7325
diff changeset
80 if ((ischar (varargin{idx}) || iscell (varargin{idx}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
81 && ! have_line_spec)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
82 [linespec, valid] = __pltopt__ (func, varargin{idx}, false);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
83 if (valid)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
84 have_line_spec = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
85 newargs = [{linespec.color}, newargs];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
86 idx++;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
87 continue;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
88 endif
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
89 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
90 if (isscalar(varargin{idx}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
91 width = varargin{idx++};
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
92 elseif (idx == nargin - 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
93 newargs = [newargs,varargin(idx++)];
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8056
diff changeset
94 elseif (ischar (varargin{idx})
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
95 && strcmpi (varargin{idx}, "basevalue")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
96 && isscalar (varargin{idx+1}))
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
97 bv = varargin{idx+1};
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
98 idx += 2;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
99 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
100 newargs = [newargs,varargin(idx:idx+1)];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
101 idx += 2;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
102 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
103 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
104 endwhile
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
105
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
106 xlen = size (x, 1);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
107 ylen = size (y, 1);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
108
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
109 if (xlen != ylen)
8664
e07e93c04080 style fixes
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
110 error ("%s: length of x and y must be equal", func);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
111 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
112 if (any (x(2:end) < x(1:end-1)))
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
113 error ("%s: x vector values must be in ascending order", func);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
114 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
115
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
116 ycols = size (y, 2);
11202
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
117 if (numel (x) > 1)
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
118 cutoff = min (diff (double(x))) / 2;
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
119 else
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
120 cutoff = 1;
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
121 endif
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
122 if (group)
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7768
diff changeset
123 delta_p = delta_m = repmat (cutoff * width / ycols, size (x));
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7768
diff changeset
124 else
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7768
diff changeset
125 delta_p = delta_m = repmat (cutoff * width, size (x));
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
126 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
127 x1 = (x - delta_m)(:)';
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
128 x2 = (x + delta_p)(:)';
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
129 xb = repmat ([x1; x1; x2; x2](:), 1, ycols);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
130
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
131 if (group)
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
132 offset = ((delta_p + delta_m) * [-(ycols - 1) / 2 : (ycols - 1) / 2]);
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
133 xb(1:4:4*ylen,:) += offset;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
134 xb(2:4:4*ylen,:) += offset;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
135 xb(3:4:4*ylen,:) += offset;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
136 xb(4:4:4*ylen,:) += offset;
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
137 y0 = zeros (size (y)) + bv;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
138 y1 = y;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
139 else
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
140 y1 = cumsum(y,2);
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
141 y0 = [zeros(ylen,1)+bv, y1(:,1:end-1)];
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
142 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
143
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
144 yb = zeros (4*ylen, ycols);
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
145 yb(1:4:4*ylen,:) = y0;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
146 yb(2:4:4*ylen,:) = y1;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
147 yb(3:4:4*ylen,:) = y1;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
148 yb(4:4:4*ylen,:) = y0;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
149
7148
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7039
diff changeset
150 xb = reshape (xb, [4, numel(xb) / 4 / ycols, ycols]);
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7039
diff changeset
151 yb = reshape (yb, [4, numel(yb) / 4 / ycols, ycols]);
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
152
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
153 if (nargout < 2)
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
154 oldh = gca ();
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
155 unwind_protect
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
156 axes (h);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
157 newplot ();
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
158
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
159 tmp = bars (h, vertical, x, y, xb, yb, width, group,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
160 have_line_spec, bv, newargs{:});
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
161 if (nargout == 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
162 varargout{1} = tmp;
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
163 endif
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
164 unwind_protect_cleanup
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
165 axes (oldh);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
166 end_unwind_protect
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
167 else
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
168 if (vertical)
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
169 varargout{1} = xb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
170 varargout{2} = yb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
171 else
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
172 varargout{1} = yb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
173 varargout{2} = xb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
174 endif
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
175 endif
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
176
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
177 endfunction
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
178
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
179 function tmp = bars (ax, vertical, x, y, xb, yb, width, group, have_color_spec, base_value, varargin)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
180
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
181 ycols = columns (y);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
182 clim = get (ax, "clim");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
183 tmp = [];
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
184
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
185 for i = 1:ycols
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
186 hg = hggroup ();
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
187 tmp = [tmp; hg];
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
188 args = __add_datasource__ ("bar", hg, {"x", "y"}, varargin{:});
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
189
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
190 if (vertical)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
191 if (! have_color_spec)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
192 if (ycols == 1)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
193 lev = clim(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
194 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
195 lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
196 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
197 h = patch(xb(:,:,i), yb(:,:,i), "FaceColor", "flat",
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
198 "cdata", lev, "parent", hg);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
199 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
200 h = patch(xb(:,:,i), yb(:,:,i), "parent", hg);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
201 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
202 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
203 if (! have_color_spec)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
204 if (ycols == 1)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
205 lev = clim(1)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
206 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
207 lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
208 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
209 h = patch(yb(:,:,i), xb(:,:,i), "FaceColor", "flat",
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
210 "cdata", lev, "parent", hg);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
211 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
212 h = patch(yb(:,:,i), xb(:,:,i), "parent", hg);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
213 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
214 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
215
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
216 if (i == 1)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
217 x_axis_range = get (ax, "xlim");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
218 h_baseline = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
219 set (h_baseline, "handlevisibility", "off");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
220 set (h_baseline, "xliminclude", "off");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
221 addlistener (ax, "xlim", @update_xlim);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
222 addlistener (h_baseline, "ydata", @update_baseline);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
223 addlistener (h_baseline, "visible", @update_baseline);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
224 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
225
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
226 ## Setup the hggroup and listeners
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
227 addproperty ("showbaseline", hg, "radio", "{on}|off");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
228 addproperty ("basevalue", hg, "data", base_value);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
229 addproperty ("baseline", hg, "data", h_baseline);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
230
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
231 addlistener (hg, "showbaseline", @show_baseline);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
232 addlistener (hg, "basevalue", @move_baseline);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
233
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
234 addproperty ("barwidth", hg, "data", width);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
235 if (group)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
236 addproperty ("barlayout", hg, "radio", "stacked|{grouped}", "grouped");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
237 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
238 addproperty ("barlayout", hg, "radio", "{stacked}|grouped", "stacked");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
239 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
240 if (vertical)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
241 addproperty ("horizontal", hg, "radio", "on|{off}", "off")
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
242 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
243 addproperty ("horizontal", hg, "radio", "{on}|off", "on")
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
244 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
245
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
246 addlistener (hg, "barwidth", @update_group);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
247 addlistener (hg, "barlayout", @update_group);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
248 addlistener (hg, "horizontal", @update_group);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
249
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
250 addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor"));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
251 addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth"));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
252 addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle"));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
253 addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor"));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
254
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
255 addlistener (hg, "edgecolor", @update_props);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
256 addlistener (hg, "linewidth", @update_props);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
257 addlistener (hg, "linestyle", @update_props);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
258 addlistener (hg, "facecolor", @update_props);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
259
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
260 if (isvector (x))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
261 addproperty ("xdata", hg, "data", x);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
262 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
263 addproperty ("xdata", hg, "data", x(:, i));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
264 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
265 addproperty ("ydata", hg, "data", y(:, i));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
266
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
267 addlistener (hg, "xdata", @update_data);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
268 addlistener (hg, "ydata", @update_data);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
269
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
270 addproperty ("bargroup", hg, "data");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
271 set (tmp, "bargroup", tmp);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
272 if (! isempty (args))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
273 set (hg, args{:});
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
274 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
275 if (i == 1)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
276 set (h_baseline, "parent", get (hg, "parent"));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
277 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
278 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
279
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
280 update_xlim (ax, []);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
281 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
282
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
283 function update_xlim (h, d)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
284 kids = get (h, "children");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
285 xlim = get (h, "xlim");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
286
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
287 for i = 1 : length (kids)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
288 obj = get (kids (i));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
289 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline"))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
290 if (any (get (obj.baseline, "xdata") != xlim))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
291 set (obj.baseline, "xdata", xlim);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
292 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
293 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
294 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
295 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
296
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
297 function update_baseline (h, d)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
298 visible = get (h, "visible");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
299 ydata = get (h, "ydata")(1);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
300
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
301 kids = get (get (h, "parent"), "children");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
302 for i = 1 : length (kids)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
303 obj = get (kids (i));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
304 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline")
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
305 && obj.baseline == h)
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
306 ## Only alter if changed to avoid recursion of the listener functions
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
307 if (! strcmpi (get (kids(i), "showbaseline"), visible))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
308 set (kids (i), "showbaseline", visible);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
309 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
310 if (! strcmpi (get (kids(i), "basevalue"), visible))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
311 set (kids (i), "basevalue", ydata);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
312 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
313 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
314 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
315 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
316
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
317 function show_baseline (h, d)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
318 persistent recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
319
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
320 ## Don't allow recursion
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
321 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
322 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
323 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
324 hlist = get (h, "bargroup");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
325 showbaseline = get (h, "showbaseline");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
326 for hh = hlist(:)'
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
327 if (hh != h)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
328 set (hh, "showbaseline", showbaseline);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
329 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
330 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
331 set (get (h, "baseline"), "visible", showbaseline);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
332 unwind_protect_cleanup
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
333 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
334 end_unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
335 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
336 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
337
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
338 function move_baseline (h, d)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
339 b0 = get (h, "basevalue");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
340 bl = get (h, "baseline");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
341
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
342 if (get (bl, "ydata") != [b0, b0])
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
343 set (bl, "ydata", [b0, b0]);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
344 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
345
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
346 if (strcmpi (get (h, "barlayout"), "grouped"))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
347 update_data (h, d);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
348 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
349 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
350
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
351 function update_props (h, d)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
352 kids = get (h, "children");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
353 set (kids, "edgecolor", get (h, "edgecolor"),
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
354 "linewidth", get (h, "linewidth"),
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
355 "linestyle", get (h, "linestyle"),
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
356 "facecolor", get (h, "facecolor"));
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
357 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
358
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
359 function update_data (h, d)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
360 persistent recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
361
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
362 ## Don't allow recursion
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
363 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
364 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
365 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
366 hlist = get (h, "bargroup");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
367 x = get (h, "xdata");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
368 if (!isvector (x))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
369 x = x(:);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
370 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
371 y = [];
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
372 for hh = hlist(:)'
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
373 ytmp = get (hh, "ydata");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
374 y = [y ytmp(:)];
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
375 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
376
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
377 [xb, yb] = bar (x, y, get (h, "barwidth"), get (h, "barlayout"),
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
378 "basevalue", get (h, "basevalue"));
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
379 ny = columns (y);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
380 vert = strcmpi (get (h, "horizontal"), "off");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
381
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
382 for i = 1:ny
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
383 hp = get (hlist(i), "children");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
384 if (vert)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
385 set (hp, "xdata", xb(:,:,i), "ydata", yb(:,:,i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
386 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
387 set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
388 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
389 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
390 unwind_protect_cleanup
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
391 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
392 end_unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
393 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
394 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
395
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
396 function update_group (h, d)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
397 persistent recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
398
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
399 ## Don't allow recursion
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
400 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
401 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
402 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
403 hlist = get (h, "bargroup");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
404 barwidth = get(h, "barwidth");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
405 barlayout = get (h, "barlayout");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
406 horizontal = get (h, "horizontal");
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
407
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
408 ## To prevent recursion, only change if modified
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
409 for hh = hlist(:)'
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
410 if (hh != h)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
411 if (get (hh, "barwidth") != barwidth)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
412 set (hh, "barwidth", barwidth);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
413 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
414 if (! strcmpi (get (hh, "barlayout"), barlayout))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
415 set (hh, "barlayout", barlayout);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
416 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
417 if (! strcmpi (get (hh, "horizontal"), horizontal))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
418 set (hh, "horizontal", horizontal);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
419 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
420 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
421 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
422 update_data (h, d);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
423 unwind_protect_cleanup
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
424 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
425 end_unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
426 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
427 endfunction