annotate scripts/plot/draw/private/__bar__.m @ 18810:d99475e26c78 stable

Fix regression in width of bars for hist() (bug #42401). * __bar__.m: For 'hist' styles with only a single bar, set group width to 1 so that bars will touch.
author Rik <rik@octave.org>
date Fri, 23 May 2014 13:04:57 -0700
parents d63878346099
children f96495e88a70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17572
diff changeset
1 ## Copyright (C) 1996-2013 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
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
28 [hax, varargin, nargin] = __plt_get_axis_arg__ (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;
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
33 histc = NA;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
34 bv = 0; # BaseValue
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
35
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
36 if (nargin > 1 && isnumeric (varargin{2}))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
37 x = varargin{1};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
38 if (isvector (x))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
39 x = x(:);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
40 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
41 y = varargin{2};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
42 if (isvector (y))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
43 y = y(:);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
44 endif
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
45 if (rows (x) != rows (y))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
46 y = varargin{1};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
47 if (isvector (y))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
48 y = y(:);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
49 endif
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
50 x = [1:rows(y)]';
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
51 idx = 2;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
52 else
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
53 if (! isvector (x))
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
54 error ("%s: X must be a vector", func);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
55 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
56 idx = 3;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
57 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
58 else
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
59 y = varargin{1};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
60 if (isvector (y))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
61 y = y(:);
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
62 endif
14872
c2dbdeaa25df maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents: 14868
diff changeset
63 x = [1:rows(y)]';
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
64 idx = 2;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
65 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
66
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
67 newargs = {};
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
68 have_line_spec = false;
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
69 while (idx <= nargin)
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8056
diff changeset
70 if (ischar (varargin{idx}) && strcmpi (varargin{idx}, "grouped"))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
71 group = true;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
72 idx++;
8190
73d6b71788c0 use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents: 8056
diff changeset
73 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "stacked"))
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
74 group = false;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
75 idx++;
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
76 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "histc"))
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
77 group = true;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
78 histc = true;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
79 idx++;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
80 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "hist"))
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
81 group = true;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
82 histc = false;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
83 idx++;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
84 else
17462
177147bf7b55 Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
Rik <rik@octave.org>
parents: 17301
diff changeset
85 if ((ischar (varargin{idx}) || iscellstr (varargin{idx}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
86 && ! have_line_spec)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
87 [linespec, valid] = __pltopt__ (func, varargin{idx}, false);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
88 if (valid)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
89 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
90 ## 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
91 ## 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
92 newargs = [{"facecolor", linespec.color}, newargs] ;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
93 idx++;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
94 continue;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
95 endif
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
96 endif
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
97 if (isscalar (varargin{idx}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
98 width = varargin{idx++};
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
99 elseif (idx == nargin)
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
100 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
101 elseif (ischar (varargin{idx})
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
102 && strcmpi (varargin{idx}, "basevalue")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
103 && isscalar (varargin{idx+1}))
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
104 bv = varargin{idx+1};
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
105 idx += 2;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
106 else
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
107 newargs = [newargs, varargin(idx:idx+1)];
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
108 idx += 2;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
109 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
110 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
111 endwhile
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
112
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
113 ngrp = rows (x);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
114 if (ngrp != rows (y))
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
115 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
116 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
117 if (any (x(2:end) < x(1:end-1)))
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
118 error ("%s: X vector values must be in ascending order", func);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
119 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
120
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
121 nbars = columns (y);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
122
18810
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
123 ## Column width is 1 for 'hist*' styles (bars touch).
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
124 if (islogical (histc))
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
125 cwidth = 1;
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
126 if (nbars == 1)
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
127 gwidth = 1;
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
128 else
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
129 gwidth = width^2;
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
130 endif
d99475e26c78 Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents: 17744
diff changeset
131 elseif (nbars == 1)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
132 cwidth = 1;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
133 gwidth = width;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
134 else
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
135 cwidth = gwidth = width;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
136 endif
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
137
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
138 ## Complicated algorithm sizes bars with unitless parameter width.
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
139 ## If width is 1.0, adjacent bars in a group are touching.
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
140 ## Otherwise, bar size is cwidth and the remaining space is split evenly on
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
141 ## either side of the bar. For the default 0.8, spacing is [0.1 0.8 0.1].
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
142 ## Groups of bars are spaced by gwidth. If gwidth is 1.0 then adjacent
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
143 ## groups will just touch.
11202
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
144 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
145 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
146 else
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
147 cutoff = 1;
1840a0ecf1fb __bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
148 endif
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
149 if (group)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
150 gdelta = cutoff * gwidth / nbars;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
151 cdelta = repmat ((1 - ((1 - cwidth) / 2)) * gdelta, size (x));
8056
9a6f4713f765 Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents: 7768
diff changeset
152 else
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
153 cdelta = repmat (cutoff * gwidth, size (x));
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
154 endif
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
155 x1 = (x - cdelta)(:)';
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
156 x2 = (x + cdelta)(:)';
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
157 xb = repmat ([x1; x1; x2; x2](:), 1, nbars);
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
158
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
159 if (group)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
160 if (islogical (histc) && histc)
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
161 offset = 2*cdelta * [0:(nbars-1)] + cdelta(1); # not centered
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
162 else
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
163 offset = 2*cdelta * [-(nbars - 1) / 2 : (nbars - 1) / 2];
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
164 endif
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
165
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
166 xb(1:4:4*ngrp,:) += offset + (1-cwidth) / 2 * (2 * gdelta);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
167 xb(2:4:4*ngrp,:) += offset + (1-cwidth) / 2 * (2 * gdelta);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
168 xb(3:4:4*ngrp,:) += offset - (1-cwidth) / 2 * (2 * gdelta);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
169 xb(4:4:4*ngrp,:) += offset - (1-cwidth) / 2 * (2 * gdelta);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
170
7325
67aef14de9c2 [project @ 2007-12-19 20:21:11 by jwe]
jwe
parents: 7215
diff changeset
171 y0 = zeros (size (y)) + bv;
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
172 y1 = y;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
173 else
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14388
diff changeset
174 y1 = cumsum (y,2);
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
175 y0 = [zeros(ngrp,1)+bv, y1(:,1:end-1)];
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
176 endif
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
177
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
178 yb = zeros (4*ngrp, nbars);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
179 yb(1:4:4*ngrp,:) = y0;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
180 yb(2:4:4*ngrp,:) = y1;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
181 yb(3:4:4*ngrp,:) = y1;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
182 yb(4:4:4*ngrp,:) = y0;
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
183
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
184 xb = reshape (xb, [4, ngrp, nbars]);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
185 yb = reshape (yb, [4, ngrp, nbars]);
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6633
diff changeset
186
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
187 if (nargout < 2)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
188 oldfig = [];
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
189 if (! isempty (hax))
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
190 oldfig = get (0, "currentfigure");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
191 endif
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
192 unwind_protect
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
193 hax = newplot (hax);
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
194
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
195 htmp = bars (hax, vertical, x, y, xb, yb, gwidth, group,
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
196 have_line_spec, bv, newargs{:});
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
197
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
198 if (! ishold (hax))
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
199 if (all (x(:,1) == fix (x(:,1))))
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
200 if (vertical)
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
201 set (hax, "xtick", x(:,1));
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
202 else
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
203 set (hax, "ytick", x(:,1));
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
204 endif
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
205 endif
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
206 ## Hack prevents color and xlim setting changes when basevalue changes.
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
207 if (vertical)
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
208 set (hax, "clim", [0 1], "xlimmode", "manual");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
209 else
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
210 set (hax, "clim", [0 1], "ylimmode", "manual");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
211 endif
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
212 endif
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
213 unwind_protect_cleanup
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
214 if (! isempty (oldfig))
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
215 set (0, "currentfigure", oldfig);
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
216 endif
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
217 end_unwind_protect
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
218 if (nargout == 1)
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
219 varargout{1} = htmp;
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
220 endif
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
221 else
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7148
diff changeset
222 if (vertical)
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
223 varargout{1} = xb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
224 varargout{2} = yb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
225 else
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
226 varargout{1} = yb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
227 varargout{2} = xb;
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
228 endif
6886
1c1d62569590 [project @ 2007-09-10 20:58:34 by jwe]
jwe
parents: 6885
diff changeset
229 endif
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
230
6540
9dcfc78da664 [project @ 2007-04-18 21:16:08 by dbateman]
dbateman
parents:
diff changeset
231 endfunction
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
232
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
233 function hglist = bars (hax, vertical, x, y, xb, yb, width, group, have_color_spec, base_value, varargin)
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
234
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
235 nbars = columns (y);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
236 clim = get (hax, "clim");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
237 hglist = [];
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
238
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
239 for i = 1:nbars
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
240 hg = hggroup ();
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
241 hglist = [hglist; hg];
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
242 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
243
9896
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)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
245 if (! have_color_spec)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
246 if (nbars == 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
247 lev = clim(1);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
248 else
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
249 lev = (i - 1) * (clim(2) - clim(1)) / (nbars - 1) - clim(1);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
250 endif
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
251 h = patch (hax, xb(:,:,i), yb(:,:,i),
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
252 "FaceColor", "flat", "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
253 else
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
254 h = patch (hax, 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
255 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
256 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
257 if (! have_color_spec)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
258 if (nbars == 1)
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
259 lev = clim(1);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
260 else
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
261 lev = (i - 1) * (clim(2) - clim(1)) / (nbars - 1) - clim(1);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
262 endif
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
263 h = patch (hax, yb(:,:,i), xb(:,:,i),
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
264 "FaceColor", "flat", "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
265 else
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
266 h = patch (hax, 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
267 endif
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
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
270 if (i == 1)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
271 ## Add baseline object the first time through loop
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
272 x_axis_range = get (hax, "xlim");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
273 h_baseline = line (hax, x_axis_range, [base_value, base_value],
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
274 "color", [0, 0, 0]);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
275 set (h_baseline, "handlevisibility", "off", "xliminclude", "off");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
276 set (h_baseline, "parent", get (hg, "parent"));
9896
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
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
279 ## 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
280 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
281 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
282 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
283
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
284 addlistener (hg, "showbaseline", {@show_baseline, "showbl"});
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
285 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
286 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
287
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
288 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
289 if (group)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
290 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
291 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
292 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
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 if (vertical)
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
295 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
296 else
11589
b0084095098e missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
297 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
298 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
299
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
300 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
301 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
302 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
303
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
304 addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor"));
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
305 addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor"));
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
306 addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle"));
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
307 addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth"));
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
308
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
309 addlistener (hg, "edgecolor", @update_props);
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
310 addlistener (hg, "facecolor", @update_props);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
311 addlistener (hg, "linestyle", @update_props);
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
312 addlistener (hg, "linewidth", @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
313
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
314 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
315 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
316 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
317 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
318 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
319 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
320
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
321 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
322 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
323
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
324 addproperty ("bargroup", hg, "data");
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
325 set (hglist, "bargroup", hglist);
17527
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17519
diff changeset
326
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17519
diff changeset
327 ## Matlab property, although Octave does not implement it.
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17519
diff changeset
328 addproperty ("hittestarea", hg, "radio", "on|{off}", "off");
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17519
diff changeset
329
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
330 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
331 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
332 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
333 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
334
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
335 update_xlim (hax, []);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
336 ## Add listeners outside of for loop to prevent constant updating during
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
337 ## creation of plot when patch objects are added.
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
338 addlistener (hax, "xlim", @update_xlim);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
339 addlistener (h_baseline, "ydata", @update_baseline);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
340 addlistener (h_baseline, "visible", @update_baseline);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
341
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
342 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
343
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
344 function update_xlim (h, ~)
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
345 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
346 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
347
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
348 for i = 1 : length (kids)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
349 obj = get (kids(i));
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
350 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
351 if (any (get (obj.baseline, "xdata") != xlim))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
352 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
353 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
354 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
355 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
356 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
357
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
358 function update_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
359 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
360 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
361
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
362 ## Search axis for a bargroup that contains this baseline handle
9896
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 (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
364 for i = 1 : length (kids)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
365 obj = get (kids(i));
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
366 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline")
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
367 && obj.baseline == h)
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
368 set (obj.bargroup, "showbaseline", visible, "basevalue", ydata);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
369 break;
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 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
372 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
373
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
374 function show_baseline (h, ~, prop = "")
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
375 persistent recursion = false;
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
376
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
377 ## 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
378 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
379 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
380 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
381 hlist = get (h, "bargroup");
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
382 if (strcmp (prop, "showbl"))
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
383 showbaseline = get (h, "showbaseline");
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
384 hlist = hlist(hlist != h); # remove current handle being updated
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
385 set (hlist, "showbaseline", showbaseline);
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
386 elseif (strcmp (prop, "visib"))
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
387 showbaseline = "on";
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
388 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
389 showbaseline = "off";
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
390 endif
15484
0133339a51c3 hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents: 15483
diff changeset
391 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
392 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
393 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
394 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
395 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
396 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
397 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
398
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
399 function move_baseline (h, ~)
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
400 persistent recursion = false;
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
401
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
402 ## Don't allow recursion
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
403 if (! recursion)
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
404 recursion = true;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
405 unwind_protect
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
406 b0 = get (h, "basevalue");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
407 bl = get (h, "baseline");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
408 set (bl, "ydata", [b0, b0]);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
409
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
410 if (strcmp (get (h, "barlayout"), "grouped"))
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
411 update_data (h);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
412 endif
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
413 unwind_protect_cleanup
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
414 recursion = false;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
415 end_unwind_protect
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
416 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
417 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
418
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
419 function update_props (h, ~)
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
420 kids = get (h, "children");
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
421 set (kids, {"edgecolor", "linewidth", "linestyle", "facecolor"},
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
422 get (h, {"edgecolor", "linewidth", "linestyle", "facecolor"}));
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
423 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
424
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
425 function update_data (h, ~)
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
426 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
427
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
428 ## 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
429 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
430 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
431 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
432 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
433 x = get (h, "xdata");
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
434 if (! isvector (x))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
435 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
436 endif
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
437 ydat = get (hlist, "ydata");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
438 if (iscell (ydat))
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
439 y = cell2mat (ydat.');
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
440 else
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
441 y = ydat;
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
442 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
443
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
444 [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
445 "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
446
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
447 vertical = strcmp (get (h, "horizontal"), "off");
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
448 for i = 1:columns (y)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
449 hp = get (hlist(i), "children");
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
450 if (vertical)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
451 set (hp, "xdata", xb(:,:,i), "ydata", yb(:,:,i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
452 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
453 set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9896
diff changeset
454 endif
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
455 endfor
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
456 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
457 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
458 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
459 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
460 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
461
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
462 function update_group (h, ~)
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
463 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
464
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
465 ## 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
466 if (! recursion)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
467 unwind_protect
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
468 recursion = true;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
469 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
470 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
471 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
472 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
473
17519
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
474 hlist = hlist(hlist != h); # remove current handle being updated
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
475 set (hlist, "barwidth", barwidth, "barlayout", barlayout,
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
476 "horizontal", horizontal);
cc9befe5d271 Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents: 17462
diff changeset
477 update_data (h);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
478 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
479 recursion = false;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
480 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
481 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
482 endfunction
17058
95c6cada5067 __bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 17032
diff changeset
483