Mercurial > octave
annotate scripts/plot/draw/private/__bar__.m @ 23947:d837f7f6e4aa
Don't label all values on bar plot when there are more than 15 bars (bug #51773).
* __bar__.m: Check that the number of bar elements to label is <= 15 before
labeling them; Otherwise, use default selected tick positions.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 25 Aug 2017 17:10:27 -0700 |
parents | 092078913d54 |
children | 196ea1ee99b8 |
rev | line source |
---|---|
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
1 ## Copyright (C) 1996-2017 John W. Eaton |
6540 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22488
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22488
diff
changeset
|
8 ## (at your option) any later version. |
6540 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22488
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22488
diff
changeset
|
13 ## GNU General Public License for more details. |
6540 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6540 | 18 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8664
diff
changeset
|
19 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
20 ## @deftypefn {} {} __bar__ (@var{vertical}, @var{func}, @dots{}) |
6895 | 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 | 23 |
24 ## Author: jwe | |
25 | |
26 function varargout = __bar__ (vertical, func, varargin) | |
6886 | 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 | 29 |
22488
a666e3ee6af8
Require gnuplot 4.4 as mininimum supported version.
Rik <rik@octave.org>
parents:
22367
diff
changeset
|
30 width = 0.8; |
6540 | 31 group = true; |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
32 histc = NA; |
22930
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
33 ## BaseValue |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
34 if (strcmp (get (hax, "yscale"), "log")) |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
35 bv = 1; |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
36 else |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
37 bv = 0; |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
38 endif |
6540 | 39 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
40 if (nargin > 1 && isnumeric (varargin{2})) |
6540 | 41 x = varargin{1}; |
6886 | 42 if (isvector (x)) |
6540 | 43 x = x(:); |
44 endif | |
45 y = varargin{2}; | |
6886 | 46 if (isvector (y)) |
6540 | 47 y = y(:); |
48 endif | |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
49 if (rows (x) != rows (y)) |
6540 | 50 y = varargin{1}; |
6886 | 51 if (isvector (y)) |
10549 | 52 y = y(:); |
6540 | 53 endif |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
54 x = [1:rows(y)]'; |
6540 | 55 idx = 2; |
56 else | |
6886 | 57 if (! isvector (x)) |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
58 error ("%s: X must be a vector", func); |
6540 | 59 endif |
60 idx = 3; | |
61 endif | |
62 else | |
63 y = varargin{1}; | |
6886 | 64 if (isvector (y)) |
6540 | 65 y = y(:); |
66 endif | |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
67 x = [1:rows(y)]'; |
6540 | 68 idx = 2; |
69 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
70 |
6540 | 71 newargs = {}; |
6886 | 72 have_line_spec = false; |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
73 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
|
74 if (ischar (varargin{idx}) && strcmpi (varargin{idx}, "grouped")) |
6540 | 75 group = true; |
20735
418ae0cb752f
Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
76 idx += 1; |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8056
diff
changeset
|
77 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "stacked")) |
6540 | 78 group = false; |
20735
418ae0cb752f
Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
79 idx += 1; |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
80 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "histc")) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
81 group = true; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19284
diff
changeset
|
82 histc = true; |
20735
418ae0cb752f
Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
83 idx += 1; |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
84 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "hist")) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
85 group = true; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
86 histc = false; |
20735
418ae0cb752f
Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
87 idx += 1; |
6540 | 88 else |
17462
177147bf7b55
Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
89 if ((ischar (varargin{idx}) || iscellstr (varargin{idx})) |
10549 | 90 && ! have_line_spec) |
91 [linespec, valid] = __pltopt__ (func, varargin{idx}, false); | |
92 if (valid) | |
93 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
|
94 ## 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
|
95 ## 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
|
96 newargs = [{"facecolor", linespec.color}, newargs] ; |
20735
418ae0cb752f
Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
97 idx += 1; |
10549 | 98 continue; |
99 endif | |
6540 | 100 endif |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14388
diff
changeset
|
101 if (isscalar (varargin{idx})) |
10549 | 102 width = varargin{idx++}; |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
103 elseif (idx == nargin) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
104 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
|
105 elseif (ischar (varargin{idx}) |
10549 | 106 && strcmpi (varargin{idx}, "basevalue") |
107 && isscalar (varargin{idx+1})) | |
7325 | 108 bv = varargin{idx+1}; |
109 idx += 2; | |
6540 | 110 else |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
111 newargs = [newargs, varargin(idx:idx+1)]; |
10549 | 112 idx += 2; |
6540 | 113 endif |
114 endif | |
115 endwhile | |
116 | |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
117 ngrp = rows (x); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
118 if (ngrp != rows (y)) |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
119 error ("%s: length of X and Y must be equal", func); |
6540 | 120 endif |
121 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
|
122 error ("%s: X vector values must be in ascending order", func); |
6540 | 123 endif |
124 | |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
125 nbars = columns (y); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
126 |
18776
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 ## 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
|
128 if (islogical (histc)) |
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 cwidth = 1; |
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
130 if (nbars == 1) |
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
131 gwidth = 1; |
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 else |
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 gwidth = width^2; |
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 endif |
d99475e26c78
Fix regression in width of bars for hist() (bug #42401).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 elseif (nbars == 1) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
136 cwidth = 1; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
137 gwidth = width; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
138 else |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
139 cwidth = gwidth = width; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
140 endif |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
141 |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
142 ## Complicated algorithm sizes bars with unitless parameter width. |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
143 ## 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
|
144 ## 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
|
145 ## 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
|
146 ## 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
|
147 ## 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
|
148 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
|
149 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
|
150 else |
1840a0ecf1fb
__bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
151 cutoff = 1; |
1840a0ecf1fb
__bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
152 endif |
6540 | 153 if (group) |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19284
diff
changeset
|
154 gdelta = cutoff * gwidth / nbars; |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
155 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
|
156 else |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
157 cdelta = repmat (cutoff * gwidth, size (x)); |
6540 | 158 endif |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
159 x1 = (x - cdelta)(:)'; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
160 x2 = (x + cdelta)(:)'; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
161 xb = repmat ([x1; x1; x2; x2](:), 1, nbars); |
6540 | 162 |
163 if (group) | |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
164 if (islogical (histc) && histc) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
165 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
|
166 else |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
167 offset = 2*cdelta * [-(nbars - 1) / 2 : (nbars - 1) / 2]; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
168 endif |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
169 |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 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
|
174 |
7325 | 175 y0 = zeros (size (y)) + bv; |
6540 | 176 y1 = y; |
177 else | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14388
diff
changeset
|
178 y1 = cumsum (y,2); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
179 y0 = [zeros(ngrp,1)+bv, y1(:,1:end-1)]; |
6540 | 180 endif |
181 | |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
182 yb = zeros (4*ngrp, nbars); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
183 yb(1:4:4*ngrp,:) = y0; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
184 yb(2:4:4*ngrp,:) = y1; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
185 yb(3:4:4*ngrp,:) = y1; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
186 yb(4:4:4*ngrp,:) = y0; |
6885 | 187 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
188 xb = reshape (xb, [4, ngrp, nbars]); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
189 yb = reshape (yb, [4, ngrp, nbars]); |
6885 | 190 |
7189 | 191 if (nargout < 2) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
192 oldfig = []; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
193 if (! isempty (hax)) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
194 oldfig = get (0, "currentfigure"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
195 endif |
7215 | 196 unwind_protect |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
197 hax = newplot (hax); |
7215 | 198 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
199 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
|
200 have_line_spec, bv, newargs{:}); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
201 |
22367
459545bc9019
Use ishold () rather than ishold (hax) for performance.
Rik <rik@octave.org>
parents:
22366
diff
changeset
|
202 if (! ishold ()) |
23947
d837f7f6e4aa
Don't label all values on bar plot when there are more than 15 bars (bug #51773).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
203 if (numel (x(:,1)) <= 15 && all (x(:,1) == fix (x(:,1)))) |
d837f7f6e4aa
Don't label all values on bar plot when there are more than 15 bars (bug #51773).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
204 ## Set manual ticks, rather than relying on autoselection, |
d837f7f6e4aa
Don't label all values on bar plot when there are more than 15 bars (bug #51773).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
205 ## when ticks are a small number of integers. |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
206 if (vertical) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
207 set (hax, "xtick", x(:,1)); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
208 else |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
209 set (hax, "ytick", x(:,1)); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
210 endif |
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 ## 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
|
213 if (vertical) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
214 set (hax, "clim", [0 1], "xlimmode", "manual"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
215 else |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
216 set (hax, "clim", [0 1], "ylimmode", "manual"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
217 endif |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
218 set (hax, "box", "on"); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
219 endif |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
220 unwind_protect_cleanup |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
221 if (! isempty (oldfig)) |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
222 set (0, "currentfigure", oldfig); |
7215 | 223 endif |
224 end_unwind_protect | |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
225 if (nargout == 1) |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
226 varargout{1} = htmp; |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
227 endif |
7189 | 228 else |
229 if (vertical) | |
6540 | 230 varargout{1} = xb; |
231 varargout{2} = yb; | |
232 else | |
233 varargout{1} = yb; | |
234 varargout{2} = xb; | |
235 endif | |
6886 | 236 endif |
7191 | 237 |
6540 | 238 endfunction |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
239 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
240 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
|
241 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
242 nbars = columns (y); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
243 clim = get (hax, "clim"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
244 hglist = []; |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
245 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
246 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
|
247 hg = hggroup (); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
248 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
|
249 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
|
250 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
251 if (vertical) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
252 if (! have_color_spec) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
253 if (nbars == 1) |
10549 | 254 lev = clim(1); |
255 else | |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
256 lev = (i - 1) * (clim(2) - clim(1)) / (nbars - 1) - clim(1); |
10549 | 257 endif |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
258 h = patch (hax, xb(:,:,i), yb(:,:,i), |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
259 "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
|
260 else |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
261 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
|
262 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
263 else |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
264 if (! have_color_spec) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
265 if (nbars == 1) |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
266 lev = clim(1); |
10549 | 267 else |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
268 lev = (i - 1) * (clim(2) - clim(1)) / (nbars - 1) - clim(1); |
10549 | 269 endif |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
270 h = patch (hax, yb(:,:,i), xb(:,:,i), |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
271 "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
|
272 else |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
273 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
|
274 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
275 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
276 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
277 if (i == 1) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
278 ## Add baseline object the first time through loop |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
279 x_axis_range = get (hax, "xlim"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
280 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
|
281 "color", [0, 0, 0]); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
282 set (h_baseline, "handlevisibility", "off", "xliminclude", "off"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
283 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
|
284 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
285 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
286 ## 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
|
287 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
|
288 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
|
289 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
|
290 |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
291 addlistener (hg, "showbaseline", {@show_baseline, "showbl"}); |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
292 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
|
293 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
|
294 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
295 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
|
296 if (group) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
297 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
|
298 else |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
299 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
|
300 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
301 if (vertical) |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
302 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
|
303 else |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
304 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
|
305 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
306 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
307 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
|
308 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
|
309 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
|
310 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
311 addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor")); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
312 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
|
313 addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle")); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
314 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
|
315 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
316 addlistener (hg, "edgecolor", @update_props); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
317 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
|
318 addlistener (hg, "linestyle", @update_props); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
319 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
|
320 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
321 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
|
322 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
|
323 else |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
324 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
|
325 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
326 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
|
327 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
328 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
|
329 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
|
330 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
331 addproperty ("bargroup", hg, "data"); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
332 set (hglist, "bargroup", hglist); |
17527
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17519
diff
changeset
|
333 |
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17519
diff
changeset
|
334 ## 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
|
335 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
|
336 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
337 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
|
338 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
|
339 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
340 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
341 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
342 update_xlim (hax, []); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
343 ## 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
|
344 ## creation of plot when patch objects are added. |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
345 addlistener (hax, "xlim", @update_xlim); |
22930
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
346 addlistener (hax, "yscale", {@update_basevalue_logscale, hg}); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
347 addlistener (h_baseline, "ydata", @update_baseline); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
348 addlistener (h_baseline, "visible", @update_baseline); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
349 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
350 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
351 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
352 function update_xlim (h, ~) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
353 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
354 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
|
355 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
|
356 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
357 for i = 1 : length (kids) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
358 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
|
359 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
|
360 if (any (get (obj.baseline, "xdata") != xlim)) |
10549 | 361 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
|
362 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
363 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
364 endfor |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
365 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
366 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
367 |
22930
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
368 function update_basevalue_logscale (hax, ~, hg) |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
369 if (strcmp (get (hax, "yscale"), "log")) |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
370 warning ("off", "Octave:negative-data-log-axis", "local"); |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
371 if (get (hg, "basevalue") == 0) |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
372 set (hg, "basevalue", 1); |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
373 endif |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
374 else |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
375 # warning ("off", "Octave:negative-data-log-axis", "local"); |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
376 if (get (hg, "basevalue") == 1) |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
377 set (hg, "basevalue", 0); |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
378 endif |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
379 endif |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
380 endfunction |
f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
381 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
382 function update_baseline (h, ~) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
383 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
384 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
|
385 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
|
386 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
387 ## 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
|
388 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
|
389 for i = 1 : length (kids) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
390 obj = get (kids(i)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
391 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") |
10549 | 392 && obj.baseline == h) |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
393 set (obj.bargroup, "showbaseline", visible, "basevalue", ydata); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
394 break; |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
395 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
396 endfor |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
397 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
398 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
399 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
400 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
|
401 persistent recursion = false; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19284
diff
changeset
|
402 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
403 ## 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
|
404 if (! recursion) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
405 unwind_protect |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
406 recursion = true; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
407 hlist = get (h, "bargroup"); |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
408 if (strcmp (prop, "showbl")) |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
409 showbaseline = get (h, "showbaseline"); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
410 hlist = hlist(hlist != h); # remove current handle being updated |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
411 set (hlist, "showbaseline", showbaseline); |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
412 elseif (strcmp (prop, "visib")) |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
413 showbaseline = "on"; |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
414 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
|
415 showbaseline = "off"; |
10549 | 416 endif |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
417 endif |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
418 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
|
419 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
|
420 recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
421 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
|
422 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
423 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
424 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
425 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
426 function move_baseline (h, ~) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
427 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
|
428 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
429 ## Don't allow recursion |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
430 if (! recursion) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
431 recursion = true; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
432 unwind_protect |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
433 b0 = get (h, "basevalue"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
434 bl = get (h, "baseline"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
435 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
|
436 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
437 if (strcmp (get (h, "barlayout"), "grouped")) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
438 update_data (h); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
439 endif |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
440 unwind_protect_cleanup |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
441 recursion = false; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
442 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
|
443 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
444 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
445 endfunction |
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 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
|
448 kids = get (h, "children"); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
449 set (kids, {"edgecolor", "linewidth", "linestyle", "facecolor"}, |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
450 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
|
451 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
452 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
453 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
|
454 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
|
455 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
456 ## 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
|
457 if (! recursion) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
458 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 recursion = true; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
460 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
|
461 x = get (h, "xdata"); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
462 if (! isvector (x)) |
10549 | 463 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
|
464 endif |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
465 ydat = get (hlist, "ydata"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
466 if (iscell (ydat)) |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
467 y = cell2mat (ydat.'); |
19284
f96495e88a70
Allow setting horizontal vector of "ydata" in bar plots (bug #43468).
Rik <rik@octave.org>
parents:
18776
diff
changeset
|
468 elseif (isvector (ydat)) |
f96495e88a70
Allow setting horizontal vector of "ydata" in bar plots (bug #43468).
Rik <rik@octave.org>
parents:
18776
diff
changeset
|
469 y = ydat(:); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
470 else |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
471 y = ydat; |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
472 endif |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
473 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
474 [xb, yb] = bar (x, y, get (h, "barwidth"), get (h, "barlayout"), |
10549 | 475 "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
|
476 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
477 vertical = strcmp (get (h, "horizontal"), "off"); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
478 for i = 1:columns (y) |
10549 | 479 hp = get (hlist(i), "children"); |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
480 if (vertical) |
10549 | 481 set (hp, "xdata", xb(:,:,i), "ydata", yb(:,:,i)); |
482 else | |
483 set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i)); | |
484 endif | |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
485 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
486 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
|
487 recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
488 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
|
489 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
490 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
491 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
492 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
493 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
|
494 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
|
495 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
496 ## 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
|
497 if (! recursion) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
498 unwind_protect |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
499 recursion = true; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
500 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
|
501 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
|
502 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
|
503 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
|
504 |
17519
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
505 hlist = hlist(hlist != h); # remove current handle being updated |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
506 set (hlist, "barwidth", barwidth, "barlayout", barlayout, |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
507 "horizontal", horizontal); |
cc9befe5d271
Overhaul bar family of plot functions.
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
508 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
|
509 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
|
510 recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
511 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
|
512 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
513 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
514 endfunction |