Mercurial > octave-nkf
annotate scripts/plot/draw/private/__stem__.m @ 19734:00e31f316a3a
Fix Matlab incompatibility of "ismatrix" (bug #42422).
* data.cc (isvector): new tests
* data.cc (isrow): documentation improved, new tests
* data.cc (iscolumn): documentation improved, new tests
* data.cc (ismatrix): is matrix now only checks the dimension due to Matlab
compatibility, documentation improved, new tests
* accumarray.m: use more appropriate function, than ismatrix
* gradient.m: use more appropriate function, than ismatrix
* num2str.m: use more appropriate functions, than ismatrix
* ntsc2rgb.m: use more appropriate function, than ismatrix
* condest.m: use more appropriate function, than ismatrix
* expm.m: use more appropriate function, than ismatrix
* onenormest.m: use more appropriate function, than ismatrix
* isocolors.m: use more appropriate function, than ismatrix
* isonormals.m: use more appropriate function, than ismatrix
* isosurface.m: use more appropriate function, than ismatrix
* __errcomm__.m: use more appropriate function, than ismatrix
* __interp_cube__.m: use more appropriate function, than ismatrix
* __marching_cube__.m: use more appropriate function, than ismatrix
* __stem__.m: use more appropriate function, than ismatrix
* stairs.m: use more appropriate function, than ismatrix
* validsetargs.m: use more appropriate functions, than ismatrix
* unique.m: use more appropriate functions, than ismatrix
* bicg.m: additional tests for numerical value
* bicgstab.m: additional tests for numerical value
* cgs.m: additional tests for numerical value
* gmres.m: additional tests for numerical value
* qmr.m: additional tests for numerical value
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Thu, 12 Feb 2015 18:34:56 +0100 |
parents | 4197fc428c7d |
children | 9fc020886ae9 |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19631
diff
changeset
|
1 ## Copyright (C) 2006-2015 Michel D. Schmid |
7217 | 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 | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
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 | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
19 ## -*- texinfo -*- |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
20 ## @deftypefn {Function File} {@var{h} =} __stem__ (@var{have_z}, @var{varargin}) |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
21 ## Undocumented internal function. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8507
diff
changeset
|
22 ## @end deftypefn |
7217 | 23 |
24 ## Author: Michel D. Schmid <michaelschmid@users.sourceforge.net> | |
25 ## Adapted-by: jwe | |
26 | |
27 function h = __stem__ (have_z, varargin) | |
28 | |
7218 | 29 if (have_z) |
30 caller = "stem3"; | |
31 else | |
32 caller = "stem"; | |
33 endif | |
7217 | 34 |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
35 [hax, varargin, nargin] = __plt_get_axis_arg__ (caller, varargin{:}); |
7217 | 36 |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
37 [x, y, z, dofill, llc, ls, mmc, ms, varargin] = ... |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
38 check_stem_arg (have_z, varargin{:}); |
7217 | 39 |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17080
diff
changeset
|
40 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17211
diff
changeset
|
41 if (! isempty (hax)) |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17080
diff
changeset
|
42 oldfig = get (0, "currentfigure"); |
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17080
diff
changeset
|
43 endif |
7217 | 44 unwind_protect |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
45 hax = newplot (hax); |
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
46 hold_state = get (hax, "nextplot"); |
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
47 set (hax, "nextplot", "add"); |
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
48 |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
49 h = []; |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
50 nx = rows (x); |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
51 h_baseline = []; |
19631
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
52 |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
53 for i = 1 : columns (x) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
54 if (have_z) |
10549 | 55 xt = x(:)'; |
56 xt = [xt; xt; NaN(1, nx)](:); | |
57 yt = y(:)'; | |
58 yt = [yt; yt; NaN(1, nx)](:); | |
59 zt = z(:)'; | |
60 zt = [zeros(1, nx); zt; NaN(1, nx)](:); | |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
61 else |
10549 | 62 xt = x(:, i)'; |
63 xt = [xt; xt; NaN(1, nx)](:); | |
64 yt = y(:, i)'; | |
65 yt = [zeros(1, nx); yt; NaN(1, nx)](:); | |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
66 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
67 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
68 if (isempty (llc)) |
10549 | 69 lc = __next_line_color__ (); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
70 else |
10549 | 71 lc = llc; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
72 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
73 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
74 if (isempty (mmc)) |
10549 | 75 mc = lc; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
76 else |
10549 | 77 mc = mmc; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
78 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
79 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
80 if (dofill) |
10549 | 81 fc = mc; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
82 else |
10549 | 83 fc = "none"; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
84 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
85 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
86 ## Must occur after __next_line_color__ in order to work correctly. |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
87 hg = hggroup (); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
88 h = [h; hg]; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
89 args = __add_datasource__ (caller, hg, {"x", "y", "z"}, varargin{:}); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
90 |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
91 if (have_z) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
92 __line__ (hax, xt, yt, zt, "color", lc, "linestyle", ls, "parent", hg); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
93 __line__ (hax, x, y, z, "color", mc, "linestyle", "none", |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
94 "marker", ms, "markerfacecolor", fc, "parent", hg); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
95 else |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
96 __line__ (hax, xt, yt, "color", lc, "linestyle", ls, "parent", hg); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
97 __line__ (hax, x(:,i), y(:, i), "color", mc, "linestyle", "none", |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
98 "marker", ms, "markerfacecolor", fc, "parent", hg); |
19631
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
99 |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
100 x_axis_range = get (hax, "xlim"); |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
101 if (isempty (h_baseline)) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
102 h_baseline = line (hax, x_axis_range, [0, 0], "color", [0, 0, 0]); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
103 set (h_baseline, "handlevisibility", "off", "xliminclude", "off"); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
104 addproperty ("basevalue", h_baseline, "data", 0); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
105 else |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
106 set (h_baseline, "xdata", x_axis_range); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
107 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
108 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
109 |
8506 | 110 ## Setup the hggroup and listeners. |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
111 addproperty ("showbaseline", hg, "radio", "{on}|off"); |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
112 addproperty ("baseline", hg, "data", h_baseline); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
113 addproperty ("basevalue", hg, "data", 0); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
114 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
115 addproperty ("color", hg, "linecolor", lc); |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
116 addproperty ("linestyle", hg, "linelinestyle", ls); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
117 addproperty ("linewidth", hg, "linelinewidth", 0.5); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
118 addproperty ("marker", hg, "linemarker", ms); |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
119 addproperty ("markeredgecolor", hg, "linemarkerfacecolor", mc); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
120 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", fc); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
121 addproperty ("markersize", hg, "linemarkersize", 6); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
122 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
123 addlistener (hg, "color", @update_props); |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
124 addlistener (hg, "linestyle", @update_props); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
125 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
126 addlistener (hg, "marker", @update_props); |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
127 addlistener (hg, "markeredgecolor", @update_props); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
128 addlistener (hg, "markerfacecolor", @update_props); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
129 addlistener (hg, "markersize", @update_props); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
130 |
19423
aea099cd1ee7
Allow stem to plot logical values (bug #43391).
Markus Bergholz <markuman+octave@gmail.com>
parents:
18463
diff
changeset
|
131 if (islogical (x)) |
aea099cd1ee7
Allow stem to plot logical values (bug #43391).
Markus Bergholz <markuman+octave@gmail.com>
parents:
18463
diff
changeset
|
132 x = double (x); |
aea099cd1ee7
Allow stem to plot logical values (bug #43391).
Markus Bergholz <markuman+octave@gmail.com>
parents:
18463
diff
changeset
|
133 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
134 addproperty ("xdata", hg, "data", x(:, i)); |
19423
aea099cd1ee7
Allow stem to plot logical values (bug #43391).
Markus Bergholz <markuman+octave@gmail.com>
parents:
18463
diff
changeset
|
135 if (islogical (y)) |
aea099cd1ee7
Allow stem to plot logical values (bug #43391).
Markus Bergholz <markuman+octave@gmail.com>
parents:
18463
diff
changeset
|
136 y = double (y); |
aea099cd1ee7
Allow stem to plot logical values (bug #43391).
Markus Bergholz <markuman+octave@gmail.com>
parents:
18463
diff
changeset
|
137 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
138 addproperty ("ydata", hg, "data", y(:, i)); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
139 if (have_z) |
10549 | 140 addproperty ("zdata", hg, "data", z(:, i)); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
141 else |
10549 | 142 addproperty ("zdata", hg, "data", []); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
143 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
144 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
145 addlistener (hg, "xdata", @update_data); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
146 addlistener (hg, "ydata", @update_data); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
147 addlistener (hg, "zdata", @update_data); |
8075
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8070
diff
changeset
|
148 |
17527
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
149 ## Matlab property, although Octave does not implement it. |
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
150 addproperty ("hittestarea", hg, "radio", "on|{off}", "off"); |
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
151 |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
152 endfor |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
153 |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
154 ## baseline listeners |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
155 if (! isempty (h_baseline)) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
156 addlistener (hax, "xlim", @update_xlim); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
157 for hg = h' |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
158 addlistener (hg, "showbaseline", @show_baseline); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
159 addlistener (hg, "visible", {@show_baseline, h}); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
160 addlistener (hg, "basevalue", @move_baseline); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
161 endfor |
19631
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
162 |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
163 addlistener (h_baseline, "basevalue", {@update_baseline, 0}); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
164 addlistener (h_baseline, "ydata", {@update_baseline, 1}); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
165 addlistener (h_baseline, "visible", {@update_baseline, 2}); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
166 set (h_baseline, "parent", get (hg(1), "parent")); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
167 endif |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
168 |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
169 ## property/value pairs |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
170 if (! isempty (args)) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
171 set (h, args{:}); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
172 endif |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
173 |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
174 if (! strcmp (hold_state, "add") && have_z) |
17430
366a51191fd7
__stem__.m: Turn on grid for stem3 plotting for Matlab compatibility.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
175 set (hax, "view", [-37.5 30], |
366a51191fd7
__stem__.m: Turn on grid for stem3 plotting for Matlab compatibility.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
176 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
177 endif |
17080
58d3fba6df17
__stem__.m: Fix typo in set() command.
Rik <rik@octave.org>
parents:
17067
diff
changeset
|
178 set (hax, "nextplot", hold_state); |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
179 |
7217 | 180 unwind_protect_cleanup |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
181 if (! isempty (oldfig)) |
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
182 set (0, "currentfigure", oldfig); |
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
183 endif |
7217 | 184 end_unwind_protect |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
185 |
7217 | 186 endfunction |
187 | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
188 function [x, y, z, dofill, lc, ls, mc, ms, args] = check_stem_arg (have_z, varargin) |
8506 | 189 |
7218 | 190 if (have_z) |
191 caller = "stem3"; | |
192 else | |
193 caller = "stem"; | |
194 endif | |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
195 nargin = nargin - 1; # account for have_z argument |
7218 | 196 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
197 num_numeric = find (cellfun ("isclass", varargin, "char"), 1) - 1; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
198 if (isempty (num_numeric)) |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
199 num_numeric = nargin; |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
200 endif |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
201 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
202 if (num_numeric < 1 || num_numeric > 3) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
203 print_usage (caller); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
204 endif |
7217 | 205 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
206 x = y = z = []; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
207 if (num_numeric == 1) |
7217 | 208 if (have_z) |
209 z = varargin{1}; | |
210 else | |
211 y = varargin{1}; | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
212 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
213 elseif (num_numeric == 2) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
214 if (have_z) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
215 error ("stem3: must define X, Y, and Z"); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
216 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
217 x = varargin{1}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
218 y = varargin{2}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
219 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
220 else # nun_numeric == 3 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
221 if (have_z) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
222 x = varargin{1}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
223 y = varargin{2}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
224 z = varargin{3}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
225 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
226 error ("stem: can not define Z for 2-D stem plot"); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
227 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
228 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
229 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
230 ## Validate numeric data |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
231 if (have_z) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
232 if (isempty (x)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
233 [nr, nc] = size (z); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
234 if (nr >= nc) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
235 x = repmat ([1:nc], nr, 1); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
236 y = repmat ([1:nr]', 1, nc); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
237 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
238 x = repmat ([1:nc], nr, 1); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
239 y = repmat ([1:nr]', 1, nc); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
240 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
241 endif |
19734
00e31f316a3a
Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19731
diff
changeset
|
242 if (! (isnumeric (x) && isnumeric (y) && isnumeric (z))) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
243 error ("stem3: X, Y, and Z must be numeric"); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
244 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
245 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
246 if (isempty (x)) |
7217 | 247 if (isvector (y)) |
10549 | 248 x = 1:length (y); |
7217 | 249 elseif (ismatrix (y)) |
10549 | 250 x = 1:rows (y); |
7217 | 251 endif |
252 endif | |
19734
00e31f316a3a
Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19731
diff
changeset
|
253 if (! (isnumeric (x) && isnumeric (y))) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
254 error ("stem: X and Y must be numeric"); |
7217 | 255 endif |
256 endif | |
257 | |
8506 | 258 ## Check sizes of x, y and z. |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
259 if (have_z) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
260 if (! size_equal (x, y, z)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
261 error ("stem3: inconsistent sizes for X, Y, and Z"); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
262 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
263 x = x(:); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
264 y = y(:); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
265 z = z(:); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
266 else |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
267 if (isvector (x)) |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
268 x = x(:); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
269 if (isvector (y)) |
10549 | 270 if (length (x) != length (y)) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
271 error ("stem: inconsistent sizes for X and Y"); |
10549 | 272 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
273 y = y(:); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
274 else |
10549 | 275 if (length (x) == rows (y)) |
276 x = repmat (x(:), 1, columns (y)); | |
277 else | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
278 error ("stem: inconsistent sizes for X and Y"); |
10549 | 279 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
280 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
281 elseif (! size_equal (x, y)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
282 error ("stem: inconsistent sizes for X and Y"); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
283 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
284 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
285 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
286 dofill = false; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
287 have_line_spec = false; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
288 ## set specifiers to default values. |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
289 [lc, ls, mc, ms] = set_default_values (); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
290 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
291 args = {}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
292 ioff = num_numeric + 1; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
293 while (ioff <= nargin) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
294 arg = varargin{ioff++}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
295 if (ischar (arg) && any (strcmpi (arg, {"fill", "filled"}))) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
296 dofill = true; |
17462
177147bf7b55
Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
Rik <rik@octave.org>
parents:
17432
diff
changeset
|
297 elseif ((ischar (arg) || iscellstr (arg)) && ! have_line_spec) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
298 [linespec, valid] = __pltopt__ (caller, arg, false); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
299 if (valid) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
300 have_line_spec = true; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
301 [lc, ls, mc, ms] = stem_line_spec (linespec); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
302 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
303 args{end+1} = arg; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
304 if (ioff <= nargin) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
305 args{end+1} = varargin{ioff++}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
306 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
307 error ('%s: No value specified for property "%s"', caller, arg); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
308 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
309 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
310 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
311 args{end+1} = arg; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
312 if (ioff <= nargin) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
313 args{end+1} = varargin{ioff++}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
314 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
315 error ('%s: No value specified for property "%s"', caller, arg); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
316 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
317 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
318 endwhile |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
319 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
320 endfunction |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
321 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
322 function [lc, ls, mc, ms] = stem_line_spec (lspec) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
323 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
324 [lc, ls, mc, ms] = set_default_values (); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
325 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
326 if (! isempty (lspec.color)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
327 lc = mc = lspec.color; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
328 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
329 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
330 if (! isempty (lspec.linestyle) && ! strcmp (lspec.linestyle, "none")) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
331 ls = lspec.linestyle; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
332 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
333 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
334 if (! isempty (lspec.marker) && ! strcmp (lspec.marker, "none")) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
335 ms = lspec.marker; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
336 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
337 |
7217 | 338 endfunction |
339 | |
340 function [lc, ls, mc, ms] = set_default_values () | |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
341 mc = []; |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
342 lc = []; |
7217 | 343 ls = "-"; |
344 ms = "o"; | |
345 endfunction | |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
346 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
347 function update_xlim (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
348 kids = get (h, "children"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
349 xlim = get (h, "xlim"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
350 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
351 for i = 1 : length (kids) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
352 obj = get (kids(i)); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
353 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline")) |
8056
9a6f4713f765
Add area, bar, quiver and stair series graphics objects. Document them
David Bateman <dbateman@free.fr>
parents:
8052
diff
changeset
|
354 if (any (get (obj.baseline, "xdata") != xlim)) |
10549 | 355 set (obj.baseline, "xdata", xlim); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
356 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
357 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
358 endfor |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
359 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
360 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
361 function update_baseline (h, ~, src) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
362 visible = get (h, "visible"); |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
363 if (src == 0) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
364 basevalue = get (h, "basevalue"); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
365 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
366 basevalue = get (h, "ydata")(1); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
367 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
368 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
369 kids = get (get (h, "parent"), "children"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
370 for i = 1 : length (kids) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
371 obj = get (kids(i)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
372 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") |
10549 | 373 && obj.baseline == h) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
374 ## Avoid lots of unnecessary listener updates |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
375 if (! strcmp (get (kids(i), "showbaseline"), visible)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
376 set (kids(i), "showbaseline", visible); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
377 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
378 if (get (kids(i), "basevalue") != basevalue) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
379 set (kids(i), "basevalue", basevalue); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
380 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
381 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
382 endfor |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
383 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
384 |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
385 function show_baseline (h, ~, hg = []) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
386 if (isempty (hg)) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
387 set (get (h, "baseline"), "visible", get (h, "showbaseline")); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
388 else |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
389 if (all (strcmp (get (hg, "visible"), "off"))) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
390 set (get (h, "baseline"), "visible", "off"); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
391 else |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
392 set (get (h, "baseline"), "visible", "on"); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
393 endif |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
394 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
395 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
396 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
397 function move_baseline (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
398 b0 = get (h, "basevalue"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
399 bl = get (h, "baseline"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
400 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
401 set (bl, "ydata", [b0, b0]); |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
402 set (bl, "basevalue", b0); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
403 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
404 kids = get (h, "children"); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
405 yt = get (h, "ydata")(:)'; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
406 ny = length (yt); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
407 yt = [b0 * ones(1, ny); yt; NaN(1, ny)](:); |
8315
e9687c313d5f
Fix callbacks in stem and quiver for change in order of children. Fix for scaling in quiver for single arrow
David Bateman <dbateman@free.fr>
parents:
8238
diff
changeset
|
408 set (kids(2), "ydata", yt); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
409 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
410 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
411 function update_props (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
412 kids = get (h, "children"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
413 set (kids(2), "color", get (h, "color"), |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
414 "linestyle", get (h, "linestyle"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
415 "linewidth", get (h, "linewidth")); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
416 set (kids(1), "color", get (h, "markeredgecolor"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
417 "marker", get (h, "marker"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
418 "markerfacecolor", get (h, "markerfacecolor"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
419 "markersize", get (h, "markersize")); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
420 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
421 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
422 function update_data (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
423 x = get (h, "xdata"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
424 y = get (h, "ydata"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
425 z = get (h, "zdata"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
426 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
427 if (!isempty (z) && size_equal (x, y, z)) |
16751
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
428 sz = min ([size(x); size(y); size(z)]); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
429 x = x(1:sz(1),1:sz(2)); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
430 y = y(1:sz(1),1:sz(2)); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
431 z = z(1:sz(1),1:sz(2)); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
432 elseif (numel (x) != numel (y)); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
433 sz = min ([size(x); size(y)]); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
434 x = x(1:sz(1),1:sz(2)); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
435 y = y(1:sz(1),1:sz(2)); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
436 endif |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
437 bl = get (h, "basevalue"); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
438 nx = numel (x); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
439 x = x(:)'; |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
440 xt = [x; x; NaN(1, nx)](:); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
441 if (! isempty (z)) |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
442 y = y(:)'; |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
443 yt = [y; y; NaN(1, nx)](:); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
444 z = z(:)'; |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
445 zt = [bl * ones(1, nx); z; NaN(1, nx)](:); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
446 else |
16751
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
447 y = y(:)'; |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
448 yt = [bl * ones(1, nx); y; NaN(1, nx)](:); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
449 zt = []; |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
450 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
451 |
16751
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
452 kids = get (h, "children"); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
453 set (kids(2), "xdata", xt, "ydata", yt, "zdata", zt); |
92811d110839
Update copies consistent subset of {x,y,z}data to children of the stem hggoup.
Ben Abbott <bpabbott@mac.com>
parents:
14868
diff
changeset
|
454 set (kids(1), "xdata", x, "ydata", y, "zdata", z); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
455 endfunction |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
456 |