Mercurial > octave-nkf
annotate scripts/plot/draw/private/__stem__.m @ 18463:2d0afa04d103
Make stemseries share the same baseline (bug #41593).
* __stem__.m: Create only one baseline line object.
Move baseline addlistener after the main loop.
Move setting prop/val after the main loop.
Add an argument to show_baseline in order to manage "visibility" hg property.
* __stem__.m (move_baseline): update the line "basevalue" property.
* stem.m: Add %!test for new behavior.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sat, 15 Feb 2014 14:14:10 +0100 |
parents | d63878346099 |
children | aea099cd1ee7 |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17572
diff
changeset
|
1 ## Copyright (C) 2006-2013 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 = []; |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
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); |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
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 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
131 addproperty ("xdata", hg, "data", x(:, i)); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
132 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
|
133 if (have_z) |
10549 | 134 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
|
135 else |
10549 | 136 addproperty ("zdata", hg, "data", []); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
137 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
138 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
139 addlistener (hg, "xdata", @update_data); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
140 addlistener (hg, "ydata", @update_data); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
141 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
|
142 |
17527
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17462
diff
changeset
|
143 ## 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
|
144 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
|
145 |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
146 endfor |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
147 |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
148 ## baseline listeners |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
149 if (! isempty (h_baseline)) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
150 addlistener (hax, "xlim", @update_xlim); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
151 for hg = h' |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
152 addlistener (hg, "showbaseline", @show_baseline); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
153 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
|
154 addlistener (hg, "basevalue", @move_baseline); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
155 endfor |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
156 |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 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
|
161 endif |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
162 |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
163 ## property/value pairs |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
164 if (! isempty (args)) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
165 set (h, args{:}); |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
166 endif |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
167 |
17067
b2cbf369837e
stem.m, stem3.m, __stem__.m: Upgrade to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16751
diff
changeset
|
168 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
|
169 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
|
170 "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
|
171 endif |
17080
58d3fba6df17
__stem__.m: Fix typo in set() command.
Rik <rik@octave.org>
parents:
17067
diff
changeset
|
172 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
|
173 |
7217 | 174 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
|
175 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
|
176 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
|
177 endif |
7217 | 178 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
|
179 |
7217 | 180 endfunction |
181 | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
182 function [x, y, z, dofill, lc, ls, mc, ms, args] = check_stem_arg (have_z, varargin) |
8506 | 183 |
7218 | 184 if (have_z) |
185 caller = "stem3"; | |
186 else | |
187 caller = "stem"; | |
188 endif | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
189 nargin = nargin - 1; # account for have_z argument |
7218 | 190 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
191 num_numeric = find (cellfun ("isclass", varargin, "char"), 1) - 1; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
192 if (isempty (num_numeric)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
193 num_numeric = nargin; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
194 endif |
8070
3b53b25e2550
Add data sources and line series
David Bateman <dbateman@free.fr>
parents:
8056
diff
changeset
|
195 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
196 if (num_numeric < 1 || num_numeric > 3) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
197 print_usage (caller); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
198 endif |
7217 | 199 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
200 x = y = z = []; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
201 if (num_numeric == 1) |
7217 | 202 if (have_z) |
203 z = varargin{1}; | |
204 else | |
205 y = varargin{1}; | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
206 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
207 elseif (num_numeric == 2) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
208 if (have_z) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
209 error ("stem3: must define X, Y, and Z"); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
210 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
211 x = varargin{1}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
212 y = varargin{2}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
213 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
214 else # nun_numeric == 3 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
215 if (have_z) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
216 x = varargin{1}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
217 y = varargin{2}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
218 z = varargin{3}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
219 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
220 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
|
221 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
222 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
223 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
224 ## Validate numeric data |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
225 if (have_z) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
226 if (isempty (x)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
227 [nr, nc] = size (z); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
228 if (nr >= nc) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
229 x = repmat ([1:nc], nr, 1); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
230 y = repmat ([1:nr]', 1, nc); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
231 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
232 x = repmat ([1:nc], nr, 1); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
233 y = repmat ([1:nr]', 1, nc); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
234 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
235 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
236 if (! (ismatrix (x) && ismatrix (y) && ismatrix (z))) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
237 error ("stem3: X, Y, and Z must be numeric"); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
238 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
239 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
240 if (isempty (x)) |
7217 | 241 if (isvector (y)) |
10549 | 242 x = 1:length (y); |
7217 | 243 elseif (ismatrix (y)) |
10549 | 244 x = 1:rows (y); |
7217 | 245 endif |
246 endif | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
247 if (! (ismatrix (x) && ismatrix (y))) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
248 error ("stem: X and Y must be numeric"); |
7217 | 249 endif |
250 endif | |
251 | |
8506 | 252 ## 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
|
253 if (have_z) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
254 if (! size_equal (x, y, z)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
255 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
|
256 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
257 x = x(:); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
258 y = y(:); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
259 z = z(:); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
260 else |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
261 if (isvector (x)) |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
262 x = x(:); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
263 if (isvector (y)) |
10549 | 264 if (length (x) != length (y)) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
265 error ("stem: inconsistent sizes for X and Y"); |
10549 | 266 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
267 y = y(:); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
268 else |
10549 | 269 if (length (x) == rows (y)) |
270 x = repmat (x(:), 1, columns (y)); | |
271 else | |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
272 error ("stem: inconsistent sizes for X and Y"); |
10549 | 273 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
274 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
275 elseif (! size_equal (x, y)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
276 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
|
277 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
278 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
279 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
280 dofill = false; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
281 have_line_spec = false; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
282 ## set specifiers to default values. |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
283 [lc, ls, mc, ms] = set_default_values (); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
284 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
285 args = {}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
286 ioff = num_numeric + 1; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
287 while (ioff <= nargin) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
288 arg = varargin{ioff++}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
289 if (ischar (arg) && any (strcmpi (arg, {"fill", "filled"}))) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
290 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
|
291 elseif ((ischar (arg) || iscellstr (arg)) && ! have_line_spec) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
292 [linespec, valid] = __pltopt__ (caller, arg, false); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
293 if (valid) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
294 have_line_spec = true; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
295 [lc, ls, mc, ms] = stem_line_spec (linespec); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
296 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
297 args{end+1} = arg; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
298 if (ioff <= nargin) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
299 args{end+1} = varargin{ioff++}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
300 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
301 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
|
302 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
303 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
304 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
305 args{end+1} = arg; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
306 if (ioff <= nargin) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
307 args{end+1} = varargin{ioff++}; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
308 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
309 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
|
310 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
311 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
312 endwhile |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
313 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
314 endfunction |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
315 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
316 function [lc, ls, mc, ms] = stem_line_spec (lspec) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
317 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
318 [lc, ls, mc, ms] = set_default_values (); |
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 if (! isempty (lspec.color)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
321 lc = mc = lspec.color; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
322 endif |
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 if (! isempty (lspec.linestyle) && ! strcmp (lspec.linestyle, "none")) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
325 ls = lspec.linestyle; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
326 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
327 |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
328 if (! isempty (lspec.marker) && ! strcmp (lspec.marker, "none")) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
329 ms = lspec.marker; |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
330 endif |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
331 |
7217 | 332 endfunction |
333 | |
334 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
|
335 mc = []; |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
336 lc = []; |
7217 | 337 ls = "-"; |
338 ms = "o"; | |
339 endfunction | |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
340 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
341 function update_xlim (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
342 kids = get (h, "children"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
343 xlim = get (h, "xlim"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
344 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
345 for i = 1 : length (kids) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
346 obj = get (kids(i)); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
347 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
|
348 if (any (get (obj.baseline, "xdata") != xlim)) |
10549 | 349 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
|
350 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
351 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
352 endfor |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
353 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
354 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
355 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
|
356 visible = get (h, "visible"); |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
357 if (src == 0) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
358 basevalue = get (h, "basevalue"); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
359 else |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
360 basevalue = get (h, "ydata")(1); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
361 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
362 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
363 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
|
364 for i = 1 : length (kids) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
365 obj = get (kids(i)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
366 if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") |
10549 | 367 && obj.baseline == h) |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
368 ## Avoid lots of unnecessary listener updates |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
369 if (! strcmp (get (kids(i), "showbaseline"), visible)) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
370 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
|
371 endif |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
372 if (get (kids(i), "basevalue") != basevalue) |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
373 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
|
374 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
375 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
376 endfor |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
377 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
378 |
18463
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
379 function show_baseline (h, ~, hg = []) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
380 if (isempty (hg)) |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
381 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
|
382 else |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
383 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
|
384 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
|
385 else |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
386 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
|
387 endif |
2d0afa04d103
Make stemseries share the same baseline (bug #41593).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17744
diff
changeset
|
388 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
389 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
390 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
391 function move_baseline (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
392 b0 = get (h, "basevalue"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
393 bl = get (h, "baseline"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
394 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
395 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
|
396 set (bl, "basevalue", b0); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
397 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
398 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
|
399 yt = get (h, "ydata")(:)'; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
400 ny = length (yt); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
401 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
|
402 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
|
403 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
404 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
405 function update_props (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
406 kids = get (h, "children"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
407 set (kids(2), "color", get (h, "color"), |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
408 "linestyle", get (h, "linestyle"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
409 "linewidth", get (h, "linewidth")); |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
410 set (kids(1), "color", get (h, "markeredgecolor"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
411 "marker", get (h, "marker"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
412 "markerfacecolor", get (h, "markerfacecolor"), |
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
413 "markersize", get (h, "markersize")); |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
414 endfunction |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
415 |
17432
77bec442a35a
Overhaul stem family of plot functions.
Rik <rik@octave.org>
parents:
17430
diff
changeset
|
416 function update_data (h, ~) |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
417 x = get (h, "xdata"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
418 y = get (h, "ydata"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
419 z = get (h, "zdata"); |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
420 |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 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
|
437 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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 endif |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
7218
diff
changeset
|
445 |
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
|
446 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
|
447 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
|
448 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
|
449 endfunction |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
450 |