Mercurial > hg > octave-lyh
annotate scripts/plot/private/__bar__.m @ 17058:95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
* scripts/plot/private/__bar__.m: Update to use new __plt_get_axis_arg__.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:46 -0700 |
parents | 53d6166f7867 |
children | 87ba70043bfc |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13886
diff
changeset
|
1 ## Copyright (C) 1996-2012 John W. Eaton |
6540 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## 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 | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
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 -*- |
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 | 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 |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
28 [hax, varargin, nargs] = __plt_get_axis_arg__ (func, varargin{:}); |
7189 | 29 |
7148 | 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 | 32 group = true; |
7325 | 33 bv = 0; |
6540 | 34 |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
35 if (nargs > 1 && isnumeric (varargin{2})) |
6540 | 36 x = varargin{1}; |
6886 | 37 if (isvector (x)) |
6540 | 38 x = x(:); |
39 endif | |
40 y = varargin{2}; | |
6886 | 41 if (isvector (y)) |
6540 | 42 y = y(:); |
43 endif | |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
44 if (rows (x) != rows (y)) |
6540 | 45 y = varargin{1}; |
6886 | 46 if (isvector (y)) |
10549 | 47 y = y(:); |
6540 | 48 endif |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
49 x = [1:rows(y)]'; |
6540 | 50 idx = 2; |
51 else | |
6886 | 52 if (! isvector (x)) |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
53 error ("%s: X must be a vector", func); |
6540 | 54 endif |
55 idx = 3; | |
56 endif | |
57 else | |
58 y = varargin{1}; | |
6886 | 59 if (isvector (y)) |
6540 | 60 y = y(:); |
61 endif | |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
62 x = [1:rows(y)]'; |
6540 | 63 idx = 2; |
64 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
65 |
6540 | 66 newargs = {}; |
6886 | 67 have_line_spec = false; |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
68 while (idx <= nargs) |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8056
diff
changeset
|
69 if (ischar (varargin{idx}) && strcmpi (varargin{idx}, "grouped")) |
6540 | 70 group = true; |
71 idx++; | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8056
diff
changeset
|
72 elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "stacked")) |
6540 | 73 group = false; |
74 idx++; | |
75 else | |
7768
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7325
diff
changeset
|
76 if ((ischar (varargin{idx}) || iscell (varargin{idx})) |
10549 | 77 && ! have_line_spec) |
78 [linespec, valid] = __pltopt__ (func, varargin{idx}, false); | |
79 if (valid) | |
80 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
|
81 ## 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
|
82 ## 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
|
83 newargs = [{"facecolor", linespec.color}, newargs] ; |
10549 | 84 idx++; |
85 continue; | |
86 endif | |
6540 | 87 endif |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14388
diff
changeset
|
88 if (isscalar (varargin{idx})) |
10549 | 89 width = varargin{idx++}; |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
90 elseif (idx == nargs) |
10549 | 91 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
|
92 elseif (ischar (varargin{idx}) |
10549 | 93 && strcmpi (varargin{idx}, "basevalue") |
94 && isscalar (varargin{idx+1})) | |
7325 | 95 bv = varargin{idx+1}; |
96 idx += 2; | |
6540 | 97 else |
10549 | 98 newargs = [newargs,varargin(idx:idx+1)]; |
99 idx += 2; | |
6540 | 100 endif |
101 endif | |
102 endwhile | |
103 | |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
104 xlen = rows (x); |
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
105 ylen = rows (y); |
6540 | 106 |
107 if (xlen != ylen) | |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
108 error ("%s: length of X and Y must be equal", func); |
6540 | 109 endif |
110 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
|
111 error ("%s: X vector values must be in ascending order", func); |
6540 | 112 endif |
113 | |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
114 ycols = columns (y); |
11202
1840a0ecf1fb
__bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
115 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
|
116 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
|
117 else |
1840a0ecf1fb
__bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
118 cutoff = 1; |
1840a0ecf1fb
__bar__.m: Permit bar() to be called with scalar inputs.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
119 endif |
6540 | 120 if (group) |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
121 delta_p = delta_m = repmat (cutoff * width / ycols, size (x)); |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
122 else |
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
7768
diff
changeset
|
123 delta_p = delta_m = repmat (cutoff * width, size (x)); |
6540 | 124 endif |
125 x1 = (x - delta_m)(:)'; | |
126 x2 = (x + delta_p)(:)'; | |
6886 | 127 xb = repmat ([x1; x1; x2; x2](:), 1, ycols); |
6540 | 128 |
129 if (group) | |
130 offset = ((delta_p + delta_m) * [-(ycols - 1) / 2 : (ycols - 1) / 2]); | |
6885 | 131 xb(1:4:4*ylen,:) += offset; |
132 xb(2:4:4*ylen,:) += offset; | |
133 xb(3:4:4*ylen,:) += offset; | |
134 xb(4:4:4*ylen,:) += offset; | |
7325 | 135 y0 = zeros (size (y)) + bv; |
6540 | 136 y1 = y; |
137 else | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14388
diff
changeset
|
138 y1 = cumsum (y,2); |
7325 | 139 y0 = [zeros(ylen,1)+bv, y1(:,1:end-1)]; |
6540 | 140 endif |
141 | |
6885 | 142 yb = zeros (4*ylen, ycols); |
143 yb(1:4:4*ylen,:) = y0; | |
144 yb(2:4:4*ylen,:) = y1; | |
145 yb(3:4:4*ylen,:) = y1; | |
146 yb(4:4:4*ylen,:) = y0; | |
147 | |
7148 | 148 xb = reshape (xb, [4, numel(xb) / 4 / ycols, ycols]); |
149 yb = reshape (yb, [4, numel(yb) / 4 / ycols, ycols]); | |
6885 | 150 |
7189 | 151 if (nargout < 2) |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
152 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); |
7215 | 153 unwind_protect |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
154 hax = newplot (hax); |
7215 | 155 |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
156 htmp = bars (hax, vertical, x, y, xb, yb, width, group, |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
157 have_line_spec, bv, newargs{:}); |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
158 unwind_protect_cleanup |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
159 if (! isempty (oldfig)) |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
160 set (0, "currentfigure", oldfig); |
7215 | 161 endif |
162 end_unwind_protect | |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
163 if (nargout == 1) |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
164 varargout{1} = htmp; |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
165 endif |
7189 | 166 else |
167 if (vertical) | |
6540 | 168 varargout{1} = xb; |
169 varargout{2} = yb; | |
170 else | |
171 varargout{1} = yb; | |
172 varargout{2} = xb; | |
173 endif | |
6886 | 174 endif |
7191 | 175 |
6540 | 176 endfunction |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
177 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
178 function tmp = bars (ax, vertical, x, y, xb, yb, width, group, have_color_spec, base_value, varargin) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
179 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
180 ycols = columns (y); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
181 clim = get (ax, "clim"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
182 tmp = []; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
183 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
184 for i = 1:ycols |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
185 hg = hggroup (); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
186 tmp = [tmp; hg]; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
187 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
|
188 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
189 if (vertical) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
190 if (! have_color_spec) |
10549 | 191 if (ycols == 1) |
192 lev = clim(1); | |
193 else | |
194 lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1); | |
195 endif | |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
196 h = patch (ax, xb(:,:,i), yb(:,:,i), "FaceColor", "flat", |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14388
diff
changeset
|
197 "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
|
198 else |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
199 h = patch (ax, 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
|
200 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
201 else |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
202 if (! have_color_spec) |
10549 | 203 if (ycols == 1) |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
204 lev = clim(1); |
10549 | 205 else |
206 lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1); | |
207 endif | |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
208 h = patch (ax, yb(:,:,i), xb(:,:,i), "FaceColor", "flat", |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14388
diff
changeset
|
209 "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
|
210 else |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
211 h = patch (ax, 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
|
212 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
213 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
214 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
215 if (i == 1) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
216 x_axis_range = get (ax, "xlim"); |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
217 h_baseline = line (ax, x_axis_range, [base_value, base_value], |
15483
b95690c001f8
if bar is given basevalue property, use it
Pantxo <pantxo.diribarne@gmail.com>
parents:
14872
diff
changeset
|
218 "color", [0, 0, 0]); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
219 set (h_baseline, "handlevisibility", "off"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
220 set (h_baseline, "xliminclude", "off"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
221 addlistener (ax, "xlim", @update_xlim); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
222 addlistener (h_baseline, "ydata", @update_baseline); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
223 addlistener (h_baseline, "visible", @update_baseline); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
224 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
225 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
226 ## Setup the hggroup and listeners |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
227 addproperty ("showbaseline", hg, "radio", "{on}|off"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
228 addproperty ("basevalue", hg, "data", base_value); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
229 addproperty ("baseline", hg, "data", h_baseline); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
230 |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
231 addlistener (hg, "showbaseline", {@show_baseline, "showbl"}); |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
232 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
|
233 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
|
234 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
235 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
|
236 if (group) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
237 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
|
238 else |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
239 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
|
240 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
241 if (vertical) |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
242 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
|
243 else |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
244 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
|
245 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
246 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
247 addlistener (hg, "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
|
248 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
|
249 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
|
250 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
251 addproperty ("edgecolor", hg, "patchedgecolor", get (h, "edgecolor")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
252 addproperty ("linewidth", hg, "patchlinewidth", get (h, "linewidth")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
253 addproperty ("linestyle", hg, "patchlinestyle", get (h, "linestyle")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
254 addproperty ("facecolor", hg, "patchfacecolor", get (h, "facecolor")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
255 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
256 addlistener (hg, "edgecolor", @update_props); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
257 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
258 addlistener (hg, "linestyle", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
259 addlistener (hg, "facecolor", @update_props); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
260 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
261 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
|
262 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
|
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 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
|
265 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
266 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
|
267 |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
268 addlistener (hg, "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
|
269 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
|
270 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
271 addproperty ("bargroup", hg, "data"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
272 set (tmp, "bargroup", tmp); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
273 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
|
274 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
|
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 if (i == 1) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
277 set (h_baseline, "parent", get (hg, "parent")); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
278 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
279 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
280 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
281 update_xlim (ax, []); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
282 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
283 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
284 function update_xlim (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
285 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
|
286 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
|
287 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
288 for i = 1 : length (kids) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
289 obj = get (kids (i)); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
290 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
|
291 if (any (get (obj.baseline, "xdata") != xlim)) |
10549 | 292 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
|
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 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
295 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
296 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
297 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
298 function update_baseline (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
299 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
|
300 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
|
301 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
302 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
|
303 for i = 1 : length (kids) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
304 obj = get (kids (i)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
305 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") |
10549 | 306 && obj.baseline == h) |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
307 ## Only alter if changed to avoid recursion of the listener functions |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
308 if (! strcmpi (get (kids(i), "showbaseline"), visible)) |
10549 | 309 set (kids (i), "showbaseline", visible); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
310 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
311 if (! strcmpi (get (kids(i), "basevalue"), visible)) |
10549 | 312 set (kids (i), "basevalue", ydata); |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
313 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
314 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
315 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
316 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
317 |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
318 function show_baseline (h, d, prop = "") |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
319 persistent recursion = false; |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
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 ## 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
|
322 if (! recursion) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
323 unwind_protect |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
324 recursion = true; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
325 hlist = get (h, "bargroup"); |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
326 if (strcmp (prop, "showbl")) |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
327 showbaseline = get (h, "showbaseline"); |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
328 for hh = hlist(:)' |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
329 if (hh != h) |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
330 set (hh, "showbaseline", showbaseline); |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
331 endif |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
332 endfor |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
333 elseif (strcmp (prop, "visib")) |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
334 showbaseline = "on"; |
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
335 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
|
336 showbaseline = "off"; |
10549 | 337 endif |
15484
0133339a51c3
hide baseline when bar group is made invisible
Pantxo <pantxo.diribarne@gmail.com>
parents:
15483
diff
changeset
|
338 endif |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
339 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
|
340 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
|
341 recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
342 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
|
343 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
344 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
345 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
346 function move_baseline (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
347 b0 = get (h, "basevalue"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
348 bl = get (h, "baseline"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
349 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
350 if (get (bl, "ydata") != [b0, b0]) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
351 set (bl, "ydata", [b0, b0]); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
352 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
353 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
354 if (strcmpi (get (h, "barlayout"), "grouped")) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
355 update_data (h, d); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
356 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
357 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
358 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
359 function update_props (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
360 kids = get (h, "children"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
361 set (kids, "edgecolor", get (h, "edgecolor"), |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
362 "linewidth", get (h, "linewidth"), |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
363 "linestyle", get (h, "linestyle"), |
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
364 "facecolor", 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
|
365 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
366 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
367 function update_data (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
368 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
|
369 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
370 ## 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
|
371 if (! recursion) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
372 unwind_protect |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
373 recursion = true; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
374 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
|
375 x = get (h, "xdata"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
376 if (!isvector (x)) |
10549 | 377 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
|
378 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
379 y = []; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
380 for hh = hlist(:)' |
10549 | 381 ytmp = get (hh, "ydata"); |
382 y = [y ytmp(:)]; | |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
383 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
384 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
385 [xb, yb] = bar (x, y, get (h, "barwidth"), get (h, "barlayout"), |
10549 | 386 "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
|
387 ny = columns (y); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
388 vert = strcmpi (get (h, "horizontal"), "off"); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
389 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
390 for i = 1:ny |
10549 | 391 hp = get (hlist(i), "children"); |
392 if (vert) | |
393 set (hp, "xdata", xb(:,:,i), "ydata", yb(:,:,i)); | |
394 else | |
395 set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i)); | |
396 endif | |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
397 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
398 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
|
399 recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
400 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
|
401 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
402 endfunction |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
403 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
404 function update_group (h, d) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
405 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
|
406 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
407 ## 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
|
408 if (! recursion) |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
409 unwind_protect |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
410 recursion = true; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
411 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
|
412 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
|
413 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
|
414 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
|
415 |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
416 ## To prevent recursion, only change if modified |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
417 for hh = hlist(:)' |
10549 | 418 if (hh != h) |
419 if (get (hh, "barwidth") != barwidth) | |
420 set (hh, "barwidth", barwidth); | |
421 endif | |
422 if (! strcmpi (get (hh, "barlayout"), barlayout)) | |
423 set (hh, "barlayout", barlayout); | |
424 endif | |
425 if (! strcmpi (get (hh, "horizontal"), horizontal)) | |
426 set (hh, "horizontal", horizontal); | |
427 endif | |
428 endif | |
9896
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
429 endfor |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
430 update_data (h, d); |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
431 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
|
432 recursion = false; |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
433 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
|
434 endif |
1aeb39118764
convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
435 endfunction |
17058
95c6cada5067
__bar__.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
17032
diff
changeset
|
436 |