Mercurial > hg > octave-lyh
annotate scripts/plot/private/__contour__.m @ 11551:84fa2ba414ee
print.m: Fix printing to eps for DOS.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 16 Jan 2011 18:31:25 -0500 |
parents | fd0a3ac60b0e |
children | c792872f8942 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 David Bateman |
7170 | 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:
8441
diff
changeset
|
19 ## -*- texinfo -*- |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8441
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{c}, @var{hg}] =} __contour__ (@dots{}) |
7170 | 21 ## Undocumented internal function. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8441
diff
changeset
|
22 ## @end deftypefn |
7170 | 23 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
24 function [c, hg] = __contour__ (varargin) |
7208 | 25 ax = varargin{1}; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
26 zlevel = varargin{2}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
27 filled = "off"; |
7170 | 28 |
7317 | 29 linespec.linestyle = "-"; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
30 linespec.color = "auto"; |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
31 edgecolor = "flat"; |
7317 | 32 for i = 3 : nargin |
33 arg = varargin {i}; | |
34 if ((ischar (arg) || iscell (arg))) | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
35 [linespec, valid] = __pltopt__ ("__contour__", arg, false); |
7317 | 36 if (isempty (linespec.color)) |
10549 | 37 linespec.color = "auto"; |
7317 | 38 endif |
10156
f481496013a2
Set default line style in __contour__
David Bateman <dbateman@free.fr>
parents:
9896
diff
changeset
|
39 if (isempty (linespec.linestyle)) |
10549 | 40 linespec.linestyle = "-"; |
10156
f481496013a2
Set default line style in __contour__
David Bateman <dbateman@free.fr>
parents:
9896
diff
changeset
|
41 endif |
7317 | 42 if (valid) |
10549 | 43 have_line_spec = true; |
44 varargin(i) = []; | |
45 break; | |
7317 | 46 endif |
47 endif | |
48 endfor | |
49 | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
50 opts = {}; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
51 i = 3; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
52 while (i < length (varargin)) |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
53 if (ischar (varargin {i})) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
54 if (strcmpi (varargin{i}, "fill")) |
10549 | 55 filled = varargin {i + 1}; |
56 varargin(i:i+1) = []; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
57 elseif (strcmpi (varargin{i}, "linecolor")) |
10549 | 58 linespec.color = varargin {i + 1}; |
59 edgecolor = linespec.color; | |
60 if (ischar (edgecolor) && strcmpi (edgecolor, "auto")) | |
61 edgecolor = "flat"; | |
62 endif | |
63 varargin(i:i+1) = []; | |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
64 elseif (strcmpi (varargin{i}, "edgecolor")) |
10549 | 65 linespec.color = varargin {i + 1}; |
66 edgecolor = linespec.color; | |
67 if (ischar (edgecolor) && strcmpi (edgecolor, "flat")) | |
68 linespec.color = "auto"; | |
69 endif | |
70 varargin(i:i+1) = []; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
71 else |
10549 | 72 opts{end+1} = varargin{i}; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
73 varargin(i) = []; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
74 opts{end+1} = varargin{i}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
75 varargin(i) = []; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
76 endif |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
77 else |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
78 i++; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
79 endif |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
80 endwhile |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
81 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
82 if (length(varargin) < 5) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
83 z1 = varargin{3}; |
10675
e5b1353695ef
__contour__.m: Correctly size X and Y when only Z specified (bug #30002).
Rik <octave@nomad.inbox5.com>
parents:
10634
diff
changeset
|
84 x1 = 1 : columns(z1); |
e5b1353695ef
__contour__.m: Correctly size X and Y when only Z specified (bug #30002).
Rik <octave@nomad.inbox5.com>
parents:
10634
diff
changeset
|
85 y1 = 1 : rows(z1); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
86 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
87 x1 = varargin{3}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
88 y1 = varargin{4}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
89 z1 = varargin{5}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
90 endif |
10634
60542efcfa2c
Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
91 if (!ismatrix (z1) || isvector (z1) || isscalar (z1)) |
60542efcfa2c
Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
92 error ("__contour__: z argument must be a matrix"); |
60542efcfa2c
Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
93 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
94 if (length (varargin) == 4 || length (varargin) == 6) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
95 vn = varargin {end}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
96 vnauto = false; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
97 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
98 vnauto = true; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
99 vn = 10; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
100 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
101 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
102 if (isscalar (vn)) |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
103 lvl = linspace (min (z1(!isinf(z1))), max (z1(!isinf(z1))), |
10549 | 104 vn + 2)(1:end-1); |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
105 else |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
106 lvl = vn; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
107 endif |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
108 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
109 if (strcmpi (filled, "on")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
110 if (isvector (x1) || isvector (y1)) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
111 [x1, y1] = meshgrid (x1, y1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
112 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
113 [nr, nc] = size (z1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
114 x0 = prepad(x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
115 x0 = postpad(x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
116 x0 = [x0(1, :); x0; x0(1, :)]; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
117 y0 = prepad(y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
118 y0 = postpad(y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1)); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
119 y0 = [y0(:, 1), y0, y0(:, 1)]; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
120 z0 = -Inf(nr+2, nc+2); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
121 z0(2:nr+1, 2:nc+1) = z1; |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
122 [c, lev] = contourc (x0, y0, z0, lvl); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
123 else |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
124 [c, lev] = contourc (x1, y1, z1, lvl); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
125 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
126 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
127 hg = hggroup (); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
128 opts = __add_datasource__ ("__countour__", hg, {"x", "y", "z"}, opts{:}); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
129 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
130 addproperty ("xdata", hg, "data", x1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
131 addproperty ("ydata", hg, "data", y1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
132 addproperty ("zdata", hg, "data", z1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
133 addproperty ("contourmatrix", hg, "data", c); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
134 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
135 addlistener (hg, "xdata", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
136 addlistener (hg, "ydata", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
137 addlistener (hg, "zdata", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
138 addlistener (hg, "contourmatrix", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
139 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
140 addproperty ("fill", hg, "radio", "on|{off}", filled); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
141 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
142 ## The properties zlevel and zlevelmode don't exist in matlab, but |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
143 ## allow the use of contourgroups with the contour3, meshc and surfc |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
144 ## functions. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
145 if (isnumeric (zlevel)) |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
146 addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", "manual"); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
147 addproperty ("zlevel", hg, "data", zlevel); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
148 else |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
149 addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", zlevel); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
150 if (ischar (zlevel) && strcmpi (zlevel, "manual")) |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
151 z = varargin{3}; |
7191 | 152 z = 2 * (min (z(:)) - max (z(:))); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
153 addproperty ("zlevel", hg, "data", z); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
154 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
155 addproperty ("zlevel", hg, "data", 0.); |
7175 | 156 endif |
157 endif | |
158 | |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
159 lvlstep = sum (abs (diff (lvl))) / (length (lvl) - 1); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
160 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
161 addproperty ("levellist", hg, "data", lev); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
162 addproperty ("levelstep", hg, "double", lvlstep); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
163 if (vnauto) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
164 addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
165 addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
166 elseif (isscalar (vn)) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
167 addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
168 addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "manual"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
169 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
170 addproperty ("levellistmode", hg, "radio", "{auto}|manual", "manual"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
171 addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
172 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
173 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
174 addproperty ("labelspacing", hg, "double", 144); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
175 addproperty ("textlist", hg, "data", lev); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
176 addproperty ("textlistmode", hg, "radio", "{auto}|manual", "auto"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
177 addproperty ("textstep", hg, "double", lvlstep); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
178 addproperty ("textstepmode", hg, "radio", "{auto}|manual", "auto"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
179 addproperty ("showtext", hg, "radio", "on|{off}", "off"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
180 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
181 addproperty ("linecolor", hg, "color", linespec.color, "{auto}|none"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
182 addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
183 addproperty ("linewidth", hg, "linelinewidth", 0.5); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
184 |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
185 ## FIXME It would be good to hide this property which is just an undocumented |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
186 ## alias for linecolor |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
187 addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none"); |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
188 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
189 addlistener (hg, "fill", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
190 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
191 addlistener (hg, "zlevelmode", @update_zlevel); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
192 addlistener (hg, "zlevel", @update_zlevel); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
193 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
194 addlistener (hg, "levellist", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
195 addlistener (hg, "levelstep", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
196 addlistener (hg, "levellistmode", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
197 addlistener (hg, "levelstepmode", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
198 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
199 addlistener (hg, "labelspacing", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
200 addlistener (hg, "textlist", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
201 addlistener (hg, "textlistmode", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
202 addlistener (hg, "textstep", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
203 addlistener (hg, "textstepmode", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
204 addlistener (hg, "showtext", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
205 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
206 addlistener (hg, "linecolor", @update_line); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
207 addlistener (hg, "linestyle", @update_line); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
208 addlistener (hg, "linewidth", @update_line); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
209 |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
210 addlistener (hg, "edgecolor", @update_edgecolor); |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
211 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
212 add_patch_children (hg); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
213 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
214 axis("tight"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
215 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
216 if (!isempty (opts)) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
217 set (hg, opts{:}); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
218 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
219 endfunction |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
220 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
221 function add_patch_children (hg) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
222 c = get (hg, "contourmatrix"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
223 lev = get (hg, "levellist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
224 fill = get (hg, "fill"); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
225 zlev = get (hg, "zlevel"); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
226 zmode = get (hg, "zlevelmode"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
227 lc = get (hg, "linecolor"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
228 lw = get (hg, "linewidth"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
229 ls = get (hg, "linestyle"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
230 filled = get (hg, "fill"); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
231 ca = gca (); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
232 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
233 if (strcmpi (lc, "auto")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
234 lc = "flat"; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
235 endif |
7170 | 236 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
237 if (strcmpi (filled, "on")) |
10354
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
238 |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
239 lvl_eps = get_lvl_eps (lev); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
240 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
241 ## Decode contourc output format. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
242 i1 = 1; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
243 ncont = 0; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
244 while (i1 < columns (c)) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
245 ncont++; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
246 cont_lev(ncont) = c(1, i1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
247 cont_len(ncont) = c(2, i1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
248 cont_idx(ncont) = i1+1; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
249 ii = i1+1:i1+cont_len(ncont); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
250 cont_area(ncont) = polyarea (c(1, ii), c(2, ii)); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
251 i1 += c(2, i1) + 1; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
252 endwhile |
7170 | 253 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
254 ## Handle for each level the case where we have (a) hole(s) in a patch. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
255 ## Those are to be filled with the color of level below or with the |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
256 ## background colour. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
257 for k = 1:numel (lev) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
258 lvl_idx = find (abs (cont_lev - lev(k)) < lvl_eps); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
259 len = numel (lvl_idx); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
260 if (len > 1) |
10549 | 261 ## mark = logical(zeros(size(lvl_idx))); |
262 mark = false (size (lvl_idx)); | |
263 a = 1; | |
264 while (a < len) | |
265 ## take 1st patch | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
266 b = a + 1; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
267 pa_idx = lvl_idx(a); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
268 ## get pointer to contour start, and contour length |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
269 curr_ct_idx = cont_idx(pa_idx); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
270 curr_ct_len = cont_len(pa_idx); |
10549 | 271 ## get contour |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
272 curr_ct = c(:, curr_ct_idx:curr_ct_idx+curr_ct_len-1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
273 b_vec = (a+1):len; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
274 next_ct_pt_vec = c(:, cont_idx(lvl_idx(b_vec))); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
275 in = inpolygon (next_ct_pt_vec(1,:), next_ct_pt_vec(2,:), |
10549 | 276 curr_ct(1, :), curr_ct(2, :)); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
277 mark(b_vec(in)) = !mark(b_vec(in)); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
278 a++; |
10549 | 279 endwhile |
280 if (numel (mark) > 0) | |
281 ## All marked contours describe a hole in a larger contour of | |
282 ## the same level and must be filled with colour of level below. | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
283 ma_idx = lvl_idx(mark); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
284 if (k > 1) |
10549 | 285 ## Find color of level below. |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
286 tmp = find(abs(cont_lev - lev(k - 1)) < lvl_eps); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
287 lvl_bel_idx = tmp(1); |
10549 | 288 ## Set color of patches found. |
289 cont_lev(ma_idx) = cont_lev(lvl_bel_idx); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
290 else |
10549 | 291 ## Set lowest level contour to NaN. |
292 cont_lev(ma_idx) = NaN; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
293 endif |
10549 | 294 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
295 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
296 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
297 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
298 ## The algorithm can create patches with the size of the plotting |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
299 ## area, we would like to draw only the patch with the highest level. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
300 del_idx = []; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
301 max_idx = find (cont_area == max (cont_area)); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
302 if (numel (max_idx) > 1) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
303 ## delete double entries |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
304 del_idx = max_idx(1:end-1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
305 cont_area(del_idx) = cont_lev(del_idx) = []; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
306 cont_len(del_idx) = cont_idx(del_idx) = []; |
7175 | 307 endif |
308 | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
309 ## Now we have everything together and can start plotting the patches |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
310 ## beginning with largest area. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
311 [tmp, svec] = sort (cont_area); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
312 len = ncont - numel (del_idx); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
313 h = []; |
8441
cc3ac5eb6be3
__contour__.m: __contour__.m: correct order of patches
Ben Abbott <bpabbott@mac.com>
parents:
8299
diff
changeset
|
314 for n = len:(-1):1 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
315 idx = svec(n); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
316 ctmp = c(:, cont_idx(idx):cont_idx(idx) + cont_len(idx) - 1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
317 if (all (ctmp(:,1) == ctmp(:,end))) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
318 ctmp(:, end) = []; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
319 else |
10549 | 320 ## Special case unclosed contours |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
321 endif |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
322 h = [h; __go_patch__(ca, "xdata", ctmp(1, :)(:), "ydata", ctmp(2, :)(:), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
323 "vertices", ctmp.', "faces", 1:(cont_len(idx)-1), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
324 "facevertexcdata", cont_lev(idx), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
325 "facecolor", "flat", "cdata", cont_lev(idx), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
326 "edgecolor", lc, "linestyle", ls, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
327 "linewidth", lw, "parent", hg)]; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
328 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
329 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
330 if (min (lev) == max (lev)) |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
331 set (ca, "clim", [min(lev)-1, max(lev)+1], "layer", "top"); |
7170 | 332 else |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
333 set (ca, "clim", [min(lev), max(lev)], "layer", "top"); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
334 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
335 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
336 ## Decode contourc output format. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
337 i1 = 1; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
338 h = []; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
339 while (i1 < length (c)) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
340 clev = c(1,i1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
341 clen = c(2,i1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
342 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
343 if (all (c(:,i1+1) == c(:,i1+clen))) |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
344 p = c(:, i1+1:i1+clen-1).'; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
345 else |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
346 p = [c(:, i1+1:i1+clen), NaN(2, 1)].'; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
347 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
348 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
349 switch (zmode) |
10549 | 350 case "none" |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
351 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
352 "zdata", [], "facecolor", "none", |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
353 "vertices", p, "faces", 1:rows(p), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
354 "facevertexcdata", clev, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
355 "edgecolor", lc, "linestyle", ls, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
356 "linewidth", lw, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
357 "cdata", clev, "parent", hg)]; |
10549 | 358 case "auto" |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
359 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
360 "zdata", clev * ones(rows(p),1), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
361 "vertices", [p, clev * ones(rows(p),1)], |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
362 "faces", 1:rows(p), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
363 "facevertexcdata", clev, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
364 "facecolor", "none", "edgecolor", lc, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
365 "linestyle", ls, "linewidth", lw, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
366 "cdata", clev, "parent", hg)]; |
10549 | 367 otherwise |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
368 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
369 "zdata", zlev * ones (rows(p), 1), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
370 "vertices", [p, zlev * ones(rows(p),1)], |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
371 "faces", 1:rows(p), |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
372 "facevertexcdata", clev, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
373 "facecolor", "none", "edgecolor", lc, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
374 "linestyle", ls, "linewidth", lw, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
375 "cdata", clev, "parent", hg)]; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
376 endswitch |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
377 i1 += clen + 1; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
378 endwhile |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
379 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
380 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
381 endfunction |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
382 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
383 function update_zlevel (h, d) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
384 z = get (h, "zlevel"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
385 zmode = get (h, "zlevelmode"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
386 kids = get (h, "children"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
387 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
388 switch (zmode) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
389 case "none" |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
390 set (kids, "zdata", []); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
391 case "auto" |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
392 for i = 1 : length (kids) |
10549 | 393 set (kids(i), "zdata", get (kids (i), "cdata") .* |
394 ones (size (get (kids (i), "xdata")))); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
395 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
396 otherwise |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
397 for i = 1 : length (kids) |
10549 | 398 set (kids(i), "zdata", z .* ones (size (get (kids (i), "xdata")))); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
399 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
400 endswitch |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
401 endfunction |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
402 |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
403 function update_edgecolor (h, d) |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
404 ec = get (h, "edgecolor"); |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
405 lc = get (h, "linecolor"); |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
406 if (ischar (ec) && strcmpi (ec, "flat")) |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
407 if (! strcmpi (lc, "auto")) |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
408 set (h, "linecolor", "auto"); |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
409 endif |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
410 elseif (! isequal (ec, lc)) |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
411 set (h, "linecolor", ec); |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
412 endif |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
413 endfunction |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
414 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
415 function update_line (h, d) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
416 lc = get (h, "linecolor"); |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
417 ec = get (h, "edgecolor"); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
418 if (strcmpi (lc, "auto")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
419 lc = "flat"; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
420 endif |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
421 if (! isequal (ec, lc)) |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
422 set (h, "edgecolor", lc); |
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
423 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
424 set (findobj (h, "type", "patch"), "edgecolor", lc, |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
425 "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle")); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
426 endfunction |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
427 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
428 function update_data (h, d) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
429 persistent recursive = false; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
430 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
431 if (!recursive) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
432 recursive = true; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
433 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
434 delete (get (h, "children")); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
435 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
436 if (strcmpi (get (h, "levellistmode"), "manual")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
437 lvl = get (h, "levellist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
438 elseif (strcmpi (get (h, "levelstepmode"), "manual")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
439 z = get (h, "zdata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
440 lvl = ceil ((max(z(:)) - min (z(:)) ./ get (h, "levelstep"))); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
441 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
442 lvl = 10; |
7170 | 443 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
444 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
445 if (strcmpi (get (h, "fill"), "on")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
446 X = get (h, "xdata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
447 Y = get (h, "ydata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
448 Z = get (h, "zdata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
449 if (isvector (X) || isvector (Y)) |
10549 | 450 [X, Y] = meshgrid (X, Y); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
451 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
452 [nr, nc] = size (Z); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
453 X0 = prepad(X, nc+1, 2 * X(1, 1) - X(1, 2), 2); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
454 X0 = postpad(X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
455 X0 = [X0(1, :); X0; X0(1, :)]; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
456 Y0 = prepad(Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
457 Y0 = postpad(Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1)); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
458 Y0 = [Y0(:, 1), Y0, Y0(:, 1)]; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
459 Z0 = -Inf(nr+2, nc+2); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
460 Z0(2:nr+1, 2:nc+1) = Z; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
461 [c, lev] = contourc (X0, Y0, Z0, lvl); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
462 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
463 [c, lev] = contourc (get (h, "xdata"), get (h, "ydata"), |
10549 | 464 get (h, "zdata"), lvl); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
465 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
466 set (h, "contourmatrix", c); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
467 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
468 if (strcmpi (get (h, "levellistmode"), "manual")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
469 ## Do nothing |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
470 elseif (strcmpi (get (h, "levelstepmode"), "manual")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
471 set (h, "levellist", lev); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
472 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
473 set (h, "levellist", lev); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
474 z = get (h, "zdata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
475 lvlstep = (max(z(:)) - min(z(:))) / 10; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
476 set (h, "levelstep", lvlstep); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
477 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
478 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
479 add_patch_children (h); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
480 update_text (h, d); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
481 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
482 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
483 recursive = false; |
7170 | 484 endfunction |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
485 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
486 function update_text (h, d) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
487 persistent recursive = false; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
488 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
489 if (!recursive) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
490 recursive = true; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
491 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
492 delete (findobj (h, "type", "text")); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
493 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
494 if (strcmpi (get (h, "textlistmode"), "manual")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
495 lvl = get (h, "textlist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
496 elseif (strcmpi (get (h, "textstepmode"), "manual")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
497 lev = get (h, "levellist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
498 |
10354
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
499 lvl_eps = get_lvl_eps (lev); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
500 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
501 stp = get (h, "textstep"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
502 t = [0, floor(cumsum(diff (lev)) / (abs(stp) - lvl_eps))]; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
503 lvl = lev([true, t(1:end-1) != t(2:end)]); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
504 set (h, "textlist", lvl); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
505 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
506 lvl = get (h, "levellist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
507 set (h, "textlist", lvl, "textstep", get (h, "levelstep")); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
508 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
509 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
510 if (strcmpi (get (h, "showtext"), "on")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
511 switch (get (h, "zlevelmode")) |
10549 | 512 case "manual" |
513 __clabel__ (get (h, "contourmatrix"), lvl, h, | |
514 get (h, "labelspacing"), get (h, "zlevel")); | |
515 case "auto" | |
516 __clabel__ (get (h, "contourmatrix"), lvl, h, | |
517 get (h, "labelspacing"), "auto"); | |
518 otherwise | |
519 __clabel__ (get (h, "contourmatrix"), lvl, h, | |
520 get (h, "labelspacing"), []); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
521 endswitch |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
522 endif |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11175
diff
changeset
|
523 |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11175
diff
changeset
|
524 recursive = false; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
525 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
526 endfunction |
10354
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
527 |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
528 function lvl_eps = get_lvl_eps (lev) |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
529 ## FIXME -- is this the right thing to do for this tolerance? Should |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
530 ## it be an absolute or relative tolerance, or switch from one to the |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
531 ## other depending on the value of lev? |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
532 if (isscalar (lev)) |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
533 lvl_eps = abs (lev) * sqrt (eps); |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
534 else |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
535 tmp = min (abs (diff (lev))); |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
536 if (tmp < 10*eps) |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
537 lvl_eps = sqrt (eps); |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
538 else |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
539 lvl_eps = tmp / 1000.0; |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
540 endif |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
541 endif |
f074aa6b2c80
__contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents:
10156
diff
changeset
|
542 endfunction |