annotate scripts/plot/private/__bar__.m @ 17032:53d6166f7867

Fix bar() update for ydata listener. scripts/plot/__bar__.m: patches should be children of the hggroup. scripts/plot/bar.m: Modify demo to modify the "ydata" hggroup property.
author Ben Abbott <bpabbott@mac.com>
date Mon, 22 Jul 2013 02:51:41 +0200
parents 0133339a51c3
children 95c6cada5067
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13886
diff changeset
1 ## Copyright (C) 1996-2012 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
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
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
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
48 if (rows (x) != rows (y))
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
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
53 x = [1:rows(y)]';
6540
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
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
66 x = [1:rows(y)]';
6540
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
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
69
6540
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;
14388
b5b49f400f9b __bar__.m: Add missing semicolon to stop internal results being printed.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
85 ## FIXME: strange parse error requires semicolon to be spaced
b5b49f400f9b __bar__.m: Add missing semicolon to stop internal results being printed.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
86 ## away from closing ']' on next line.
b5b49f400f9b __bar__.m: Add missing semicolon to stop internal results being printed.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
87 newargs = [{"facecolor", linespec.color}, newargs] ;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
88 idx++;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
89 continue;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
90 endif
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
91 endif
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
92 if (isscalar (varargin{idx}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
93 width = varargin{idx++};
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
94 elseif (idx == nargin - 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
95 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
96 elseif (ischar (varargin{idx})
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
97 && strcmpi (varargin{idx}, "basevalue")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
98 && isscalar (varargin{idx+1}))
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
99 bv = varargin{idx+1};
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
100 idx += 2;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
101 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
102 newargs = [newargs,varargin(idx:idx+1)];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
103 idx += 2;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
104 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
105 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
106 endwhile
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
107
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
108 xlen = rows (x);
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
109 ylen = rows (y);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
110
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
111 if (xlen != ylen)
8664
e07e93c04080 style fixes
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
112 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
113 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
114 if (any (x(2:end) < x(1:end-1)))
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
115 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
116 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
117
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
118 ycols = columns (y);
11202
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
119 if (numel (x) > 1)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
120 cutoff = min (diff (double (x))) / 2;
11202
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
121 else
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
122 cutoff = 1;
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
123 endif
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
124 if (group)
8056
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 / ycols, size (x));
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7768
diff changeset
126 else
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7768
diff changeset
127 delta_p = delta_m = repmat (cutoff * width, size (x));
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
128 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
129 x1 = (x - delta_m)(:)';
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
130 x2 = (x + delta_p)(:)';
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
131 xb = repmat ([x1; x1; x2; x2](:), 1, ycols);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
132
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
133 if (group)
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
134 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
135 xb(1:4:4*ylen,:) += offset;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
136 xb(2:4:4*ylen,:) += offset;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
137 xb(3:4:4*ylen,:) += offset;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
138 xb(4:4:4*ylen,:) += offset;
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
139 y0 = zeros (size (y)) + bv;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
140 y1 = y;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
141 else
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
142 y1 = cumsum (y,2);
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
143 y0 = [zeros(ylen,1)+bv, y1(:,1:end-1)];
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
144 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
145
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
146 yb = zeros (4*ylen, ycols);
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
147 yb(1:4:4*ylen,:) = y0;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
148 yb(2:4:4*ylen,:) = y1;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
149 yb(3:4:4*ylen,:) = y1;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
150 yb(4:4:4*ylen,:) = y0;
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
151
7148
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7039
diff changeset
152 xb = reshape (xb, [4, numel(xb) / 4 / ycols, ycols]);
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7039
diff changeset
153 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
154
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
155 if (nargout < 2)
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
156 oldh = gca ();
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
157 unwind_protect
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
158 axes (h);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
159 newplot ();
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
160
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
161 tmp = bars (h, vertical, x, y, xb, yb, width, group,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
162 have_line_spec, bv, newargs{:});
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
163 if (nargout == 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
164 varargout{1} = tmp;
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
165 endif
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
166 unwind_protect_cleanup
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
167 axes (oldh);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
168 end_unwind_protect
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
169 else
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
170 if (vertical)
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
171 varargout{1} = xb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
172 varargout{2} = yb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
173 else
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
174 varargout{1} = yb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
175 varargout{2} = xb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
176 endif
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
177 endif
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
178
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
179 endfunction
9896
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 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
182
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
183 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
184 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
185 tmp = [];
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
186
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
187 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
188 hg = hggroup ();
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
189 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
190 args = __add_datasource__ ("bar", hg, {"x", "y"}, varargin{:});
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
191
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
192 if (vertical)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
193 if (! have_color_spec)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
194 if (ycols == 1)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
195 lev = clim(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
196 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
197 lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
198 endif
17032
53d6166f7867 Fix bar() update for ydata listener.
Ben Abbott <bpabbott@mac.com>
parents: 15484
diff changeset
199 h = patch (hg, xb(:,:,i), yb(:,:,i), "FaceColor", "flat",
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
200 "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
201 else
17032
53d6166f7867 Fix bar() update for ydata listener.
Ben Abbott <bpabbott@mac.com>
parents: 15484
diff changeset
202 h = patch (hg, 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
203 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
204 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
205 if (! have_color_spec)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
206 if (ycols == 1)
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
207 lev = clim(1);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
208 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
209 lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
210 endif
17032
53d6166f7867 Fix bar() update for ydata listener.
Ben Abbott <bpabbott@mac.com>
parents: 15484
diff changeset
211 h = patch (hg, yb(:,:,i), xb(:,:,i), "FaceColor", "flat",
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
212 "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
213 else
17032
53d6166f7867 Fix bar() update for ydata listener.
Ben Abbott <bpabbott@mac.com>
parents: 15484
diff changeset
214 h = patch (hg, 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
215 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
216 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
217
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
218 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
219 x_axis_range = get (ax, "xlim");
15483
b95690c001f8 if bar is given basevalue property, use it
Pantxo <pantxo.diribarne@gmail.com>
parents: 14872
diff changeset
220 h_baseline = line (x_axis_range, [base_value, base_value],
b95690c001f8 if bar is given basevalue property, use it
Pantxo <pantxo.diribarne@gmail.com>
parents: 14872
diff changeset
221 "color", [0, 0, 0]);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
222 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
223 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
224 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
225 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
226 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
227 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
228
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
229 ## 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
230 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
231 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
232 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
233
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
234 addlistener (hg, "showbaseline", {@show_baseline, "showbl"});
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
235 addlistener (hg, "visible", {@show_baseline, "visib"});
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
236 addlistener (hg, "basevalue", @move_baseline);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
237
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
238 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
239 if (group)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
240 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
241 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
242 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
243 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
244 if (vertical)
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
245 addproperty ("horizontal", hg, "radio", "on|{off}", "off");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
246 else
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
247 addproperty ("horizontal", hg, "radio", "{on}|off", "on");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
248 endif
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 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
251 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
252 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
253
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
254 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
255 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
256 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
257 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
258
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
259 addlistener (hg, "edgecolor", @update_props);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
260 addlistener (hg, "linewidth", @update_props);
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
261 addlistener (hg, "linestyle", @update_props);
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
262 addlistener (hg, "facecolor", @update_props);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
263
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
264 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
265 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
266 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
267 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
268 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
269 addproperty ("ydata", hg, "data", y(:, i));
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
270
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
271 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
272 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
273
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
274 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
275 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
276 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
277 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
278 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
279 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
280 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
281 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
282 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
283
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
284 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
285 endfunction
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 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
288 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
289 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
290
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
291 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
292 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
293 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
294 if (any (get (obj.baseline, "xdata") != xlim))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
295 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
296 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
297 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
298 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
299 endfunction
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 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
302 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
303 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
304
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
305 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
306 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
307 obj = get (kids (i));
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
308 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline")
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
309 && 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
310 ## 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
311 if (! strcmpi (get (kids(i), "showbaseline"), visible))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
312 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
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 if (! strcmpi (get (kids(i), "basevalue"), visible))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
315 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
316 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
317 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
318 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
319 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
320
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
321 function show_baseline (h, d, prop = "")
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
322 persistent recursion = false;
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
323
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
324 ## 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
325 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
326 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
327 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
328 hlist = get (h, "bargroup");
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
329 if (strcmp (prop, "showbl"))
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
330 showbaseline = get (h, "showbaseline");
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
331 for hh = hlist(:)'
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
332 if (hh != h)
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
333 set (hh, "showbaseline", showbaseline);
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
334 endif
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
335 endfor
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
336 elseif (strcmp (prop, "visib"))
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
337 showbaseline = "on";
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
338 if (all (strcmp (get (hlist, "visible"), "off")))
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
339 showbaseline = "off";
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
340 endif
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
341 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
342 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
343 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
344 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
345 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
346 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
347 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
348
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
349 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
350 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
351 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
352
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
353 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
354 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
355 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
356
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
357 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
358 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
359 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
360 endfunction
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 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
363 kids = get (h, "children");
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
364 set (kids, "edgecolor", get (h, "edgecolor"),
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
365 "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
366 "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
367 "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
368 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
369
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
370 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
371 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
372
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
373 ## 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
374 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
375 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
376 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
377 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
378 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
379 if (!isvector (x))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
380 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
381 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
382 y = [];
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
383 for hh = hlist(:)'
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
384 ytmp = get (hh, "ydata");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
385 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
386 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
387
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
388 [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
389 "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
390 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
391 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
392
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
393 for i = 1:ny
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
394 hp = get (hlist(i), "children");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
395 if (vert)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
396 set (hp, "xdata", xb(:,:,i), "ydata", yb(:,:,i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
397 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
398 set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
399 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
400 endfor
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_cleanup
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
402 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
403 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
404 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
405 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
406
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
407 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
408 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
409
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
410 ## 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
411 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
412 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
413 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
414 hlist = get (h, "bargroup");
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
415 barwidth = get (h, "barwidth");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
416 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
417 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
418
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
419 ## 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
420 for hh = hlist(:)'
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
421 if (hh != h)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
422 if (get (hh, "barwidth") != barwidth)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
423 set (hh, "barwidth", barwidth);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
424 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
425 if (! strcmpi (get (hh, "barlayout"), barlayout))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
426 set (hh, "barlayout", barlayout);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
427 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
428 if (! strcmpi (get (hh, "horizontal"), horizontal))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
429 set (hh, "horizontal", horizontal);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
430 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
431 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
432 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
433 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
434 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
435 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
436 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
437 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
438 endfunction