Mercurial > octave-nkf
annotate scripts/plot/draw/private/__contour__.m @ 17572:7bb76a22cde1
maint: Split scripts/plot directory into 4 pieces.
scripts/gui : user-interface functions
scripts/plot/appearance : functions controlling plot appearance
scripts/plot/draw : plotting functions which produce graphs
scripts/plot/util : low-level plotting functions and utilities.
* scripts/gui/guidata.m, scripts/gui/guihandles.m, scripts/gui/module.mk,
scripts/gui/private/__file_filter__.m,
scripts/gui/private/__fltk_file_filter__.m,
scripts/gui/private/__is_function__.m, scripts/gui/private/__uigetdir_fltk__.m,
scripts/gui/private/__uigetfile_fltk__.m,
scripts/gui/private/__uiobject_split_args__.m,
scripts/gui/private/__uiputfile_fltk__.m, scripts/gui/uicontextmenu.m,
scripts/gui/uicontrol.m, scripts/gui/uigetdir.m, scripts/gui/uigetfile.m,
scripts/gui/uimenu.m, scripts/gui/uipanel.m, scripts/gui/uipushtool.m,
scripts/gui/uiputfile.m, scripts/gui/uiresume.m, scripts/gui/uitoggletool.m,
scripts/gui/uitoolbar.m, scripts/gui/uiwait.m, scripts/gui/waitbar.m,
scripts/gui/waitforbuttonpress.m: Moved from scripts/plot to scripts/gui
* scripts/plot/appearance/__clabel__.m,
scripts/plot/appearance/__getlegenddata__.m, scripts/plot/appearance/axis.m,
scripts/plot/appearance/box.m, scripts/plot/appearance/caxis.m,
scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m,
scripts/plot/appearance/diffuse.m, scripts/plot/appearance/grid.m,
scripts/plot/appearance/gtext.m, scripts/plot/appearance/hidden.m,
scripts/plot/appearance/legend.m,
scripts/plot/appearance/orient.m, scripts/plot/appearance/pbaspect.m,
scripts/plot/appearance/private/__axis_label__.m,
scripts/plot/appearance/private/__axis_limits__.m,
scripts/plot/appearance/shading.m, scripts/plot/appearance/specular.m,
scripts/plot/appearance/text.m, scripts/plot/appearance/title.m,
scripts/plot/appearance/view.m, scripts/plot/appearance/whitebg.m,
scripts/plot/appearance/xlabel.m, scripts/plot/appearance/xlim.m,
scripts/plot/appearance/ylabel.m, scripts/plot/appearance/ylim.m,
scripts/plot/appearance/zlabel.m, scripts/plot/appearance/zlim.m:
Moved from scripts/plot to subdir appearance.
* scripts/plot/draw/area.m, scripts/plot/draw/bar.m, scripts/plot/draw/barh.m,
scripts/plot/draw/colorbar.m, scripts/plot/draw/comet.m,
scripts/plot/draw/comet3.m, scripts/plot/draw/compass.m,
scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m,
scripts/plot/draw/contourc.m, scripts/plot/draw/contourf.m,
scripts/plot/draw/cylinder.m, scripts/plot/draw/ellipsoid.m,
scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m,
scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m,
scripts/plot/draw/ezmeshc.m, scripts/plot/draw/ezplot.m,
scripts/plot/draw/ezplot3.m, scripts/plot/draw/ezpolar.m,
scripts/plot/draw/ezsurf.m, scripts/plot/draw/ezsurfc.m,
scripts/plot/draw/feather.m, scripts/plot/draw/fill.m,
scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m,
scripts/plot/draw/isocolors.m, scripts/plot/draw/isonormals.m,
scripts/plot/draw/isosurface.m, scripts/plot/draw/line.m,
scripts/plot/draw/loglog.m, scripts/plot/draw/loglogerr.m,
scripts/plot/draw/mesh.m, scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m,
scripts/plot/draw/pareto.m,
scripts/plot/draw/patch.m, scripts/plot/draw/pcolor.m,
scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m, scripts/plot/draw/pie3.m,
scripts/plot/draw/plot.m, scripts/plot/draw/plot3.m,
scripts/plot/draw/plotmatrix.m, scripts/plot/draw/plotyy.m,
scripts/plot/draw/polar.m, scripts/plot/draw/private/__add_datasource__.m,
scripts/plot/draw/private/__bar__.m, scripts/plot/draw/private/__contour__.m,
scripts/plot/draw/private/__errcomm__.m,
scripts/plot/draw/private/__errplot__.m,
scripts/plot/draw/private/__ezplot__.m,
scripts/plot/draw/private/__interp_cube__.m,
scripts/plot/draw/private/__line__.m,
scripts/plot/draw/private/__marching_cube__.m,
scripts/plot/draw/private/__patch__.m, scripts/plot/draw/private/__pie__.m,
scripts/plot/draw/private/__plt__.m, scripts/plot/draw/private/__quiver__.m,
scripts/plot/draw/private/__scatter__.m, scripts/plot/draw/private/__stem__.m,
scripts/plot/draw/quiver.m, scripts/plot/draw/quiver3.m,
scripts/plot/draw/rectangle.m, scripts/plot/draw/ribbon.m,
scripts/plot/draw/rose.m, scripts/plot/draw/scatter.m,
scripts/plot/draw/scatter3.m, scripts/plot/draw/semilogx.m,
scripts/plot/draw/semilogxerr.m, scripts/plot/draw/semilogy.m,
scripts/plot/draw/semilogyerr.m, scripts/plot/draw/shrinkfaces.m,
scripts/plot/draw/slice.m, scripts/plot/draw/sombrero.m,
scripts/plot/draw/sphere.m, scripts/plot/draw/stairs.m,
scripts/plot/draw/stem.m, scripts/plot/draw/stem3.m,
scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m,
scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m,
scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m,
scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m,
scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m,
scripts/plot/draw/waterfall.m: Moved from plot/ to subdir draw.
* scripts/plot/util/__actual_axis_position__.m,
scripts/plot/util/__default_plot_options__.m,
scripts/plot/util/__gnuplot_drawnow__.m,
scripts/plot/util/__next_line_color__.m,
scripts/plot/util/__next_line_style__.m,
scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/__pltopt__.m,
scripts/plot/util/allchild.m, scripts/plot/util/ancestor.m,
scripts/plot/util/axes.m, scripts/plot/util/cla.m, scripts/plot/util/clf.m,
scripts/plot/util/close.m, scripts/plot/util/closereq.m,
scripts/plot/util/colstyle.m, scripts/plot/util/copyobj.m,
scripts/plot/util/figure.m, scripts/plot/util/findall.m,
scripts/plot/util/findfigs.m, scripts/plot/util/findobj.m,
scripts/plot/util/gca.m, scripts/plot/util/gcbf.m, scripts/plot/util/gcbo.m,
scripts/plot/util/gcf.m, scripts/plot/util/gco.m, scripts/plot/util/ginput.m,
scripts/plot/util/gnuplot_binary.in, scripts/plot/util/graphics_toolkit.m,
scripts/plot/util/hdl2struct.m, scripts/plot/util/hggroup.m,
scripts/plot/util/hold.m, scripts/plot/util/isaxes.m,
scripts/plot/util/isfigure.m, scripts/plot/util/ishghandle.m,
scripts/plot/util/ishold.m, scripts/plot/util/isprop.m,
scripts/plot/util/linkprop.m, scripts/plot/util/meshgrid.m,
scripts/plot/util/ndgrid.m,
scripts/plot/util/newplot.m, scripts/plot/util/print.m,
scripts/plot/util/printd.m, scripts/plot/util/private/__add_default_menu__.m,
scripts/plot/util/private/__fltk_ginput__.m,
scripts/plot/util/private/__fltk_print__.m,
scripts/plot/util/private/__ghostscript__.m,
scripts/plot/util/private/__gnuplot_get_var__.m,
scripts/plot/util/private/__gnuplot_ginput__.m,
scripts/plot/util/private/__gnuplot_has_feature__.m,
scripts/plot/util/private/__gnuplot_has_terminal__.m,
scripts/plot/util/private/__gnuplot_open_stream__.m,
scripts/plot/util/private/__gnuplot_print__.m,
scripts/plot/util/private/__gnuplot_version__.m,
scripts/plot/util/private/__go_draw_axes__.m,
scripts/plot/util/private/__go_draw_figure__.m,
scripts/plot/util/private/__print_parse_opts__.m,
scripts/plot/util/private/__tight_eps_bbox__.m, scripts/plot/util/refresh.m,
scripts/plot/util/refreshdata.m, scripts/plot/util/saveas.m,
scripts/plot/util/shg.m, scripts/plot/util/struct2hdl.m,
scripts/plot/util/subplot.m: Moved from plot to subdir util.
* etc/HACKING: Updated directory structure info.
* scripts/Makefile.am, scripts/plot/appearance/module.mk,
scripts/plot/draw/module.mk, scripts/plot/util/module.mk:
Added new directories to build system.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 04 Oct 2013 17:09:08 -0700 |
parents | scripts/plot/private/__contour__.m@76614e624818 |
children | d63878346099 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13156
diff
changeset
|
1 ## Copyright (C) 2007-2012 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 |
17466 | 29 linespec.color = "auto"; |
7317 | 30 linespec.linestyle = "-"; |
17466 | 31 for i = 3:2:nargin |
32 arg = varargin{i}; | |
33 if (ischar (arg) || iscellstr (arg)) | |
34 [lspec, valid] = __pltopt__ ("__contour__", arg, false); | |
7317 | 35 if (valid) |
10549 | 36 have_line_spec = true; |
37 varargin(i) = []; | |
17466 | 38 linespec = lspec; |
39 if (isempty (linespec.color)) | |
40 linespec.color = "auto"; | |
41 endif | |
42 if (isempty (linespec.linestyle)) | |
43 linespec.linestyle = "-"; | |
44 endif | |
10549 | 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)) |
17466 | 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")) |
17466 | 55 filled = varargin{i+1}; |
10549 | 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")) |
17466 | 58 linespec.color = varargin{i+1}; |
10549 | 59 varargin(i:i+1) = []; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
60 else |
17466 | 61 opts(end+(1:2)) = varargin(i:i+1); |
62 varargin(i:i+1) = []; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
63 endif |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
64 else |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
65 i++; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
66 endif |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
67 endwhile |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
68 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
69 if (length (varargin) < 5) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
70 z1 = varargin{3}; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
71 x1 = 1 : columns (z1); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
72 y1 = 1 : rows (z1); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
73 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
74 x1 = varargin{3}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
75 y1 = varargin{4}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
76 z1 = varargin{5}; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
77 endif |
17466 | 78 if (! ismatrix (z1) || ! ismatrix (x1) || ! ismatrix (y1)) |
79 error ("__contour__: X, Y, and Z must be matrices"); | |
10634
60542efcfa2c
Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
80 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
81 if (length (varargin) == 4 || length (varargin) == 6) |
16911 | 82 vn = varargin{end}; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
83 vnauto = false; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
84 else |
17466 | 85 vn = 10; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
86 vnauto = true; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
87 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
88 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
89 if (isscalar (vn)) |
17466 | 90 ## FIXME: The levels should be determined similarly to {x,y,z}ticks |
91 ## so that they aren't set at extremely odd values. | |
92 lvl = linspace (min (z1(!isinf (z1))), max (z1(!isinf (z1))), vn + 2); | |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
93 ## Strip off max outlier, min must stay for contourf hole algorithm. |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
94 lvl = lvl(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
|
95 else |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
96 lvl = sort (vn); |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
97 endif |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
98 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
99 if (strcmpi (filled, "on")) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
100 if (isvector (x1) || isvector (y1)) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
101 [x1, y1] = meshgrid (x1, y1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
102 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
103 [nr, nc] = size (z1); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
104 x0 = prepad (x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
105 x0 = postpad (x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
106 x0 = [x0(1, :); x0; x0(1, :)]; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
107 y0 = prepad (y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
108 y0 = postpad (y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1)); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
109 y0 = [y0(:, 1), y0, y0(:, 1)]; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
110 z0 = -Inf (nr+2, nc+2); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
111 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
|
112 [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
|
113 else |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8289
diff
changeset
|
114 [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
|
115 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
116 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
117 hg = hggroup (); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
118 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
|
119 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
120 addproperty ("xdata", hg, "data", x1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
121 addproperty ("ydata", hg, "data", y1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
122 addproperty ("zdata", hg, "data", z1); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
123 addproperty ("contourmatrix", hg, "data", c); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
124 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
125 addlistener (hg, "xdata", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
126 addlistener (hg, "ydata", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
127 addlistener (hg, "zdata", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
128 addlistener (hg, "contourmatrix", @update_data); |
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 ("fill", hg, "radio", "on|{off}", filled); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
131 |
17167
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
132 ## The properties zlevel and zlevelmode don't exist in matlab, but allow the |
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
133 ## use of contourgroups with the contour3, meshc, and surfc functions. |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
134 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
|
135 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
|
136 addproperty ("zlevel", hg, "data", zlevel); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
137 else |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
138 addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", zlevel); |
17466 | 139 addproperty ("zlevel", hg, "data", 0.); |
7175 | 140 endif |
141 | |
17466 | 142 lvlstep = sum (diff (lvl)) / (length (lvl) - 1); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
143 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
144 addproperty ("levellist", hg, "data", lev); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
145 addproperty ("levelstep", hg, "double", lvlstep); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
146 if (vnauto) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
147 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
|
148 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
|
149 elseif (isscalar (vn)) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
150 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
|
151 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
|
152 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
153 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
|
154 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
|
155 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
156 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
157 addproperty ("labelspacing", hg, "double", 144); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
158 addproperty ("textlist", hg, "data", lev); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
159 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
|
160 addproperty ("textstep", hg, "double", lvlstep); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
161 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
|
162 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
|
163 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
164 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
|
165 addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
166 addproperty ("linewidth", hg, "linelinewidth", 0.5); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
167 |
17527
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17525
diff
changeset
|
168 ## Matlab property, although Octave does not implement it. |
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17525
diff
changeset
|
169 addproperty ("hittestarea", hg, "radio", "on|{off}", "off"); |
76614e624818
Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents:
17525
diff
changeset
|
170 |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
171 addlistener (hg, "fill", {@update_data, "fill"}); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
172 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
173 addlistener (hg, "zlevelmode", @update_zlevel); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
174 addlistener (hg, "zlevel", @update_zlevel); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
175 |
16911 | 176 addlistener (hg, "levellist", {@update_data, "levellist"}); |
177 addlistener (hg, "levelstep", {@update_data, "levelstep"}); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
178 addlistener (hg, "levellistmode", @update_data); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
179 addlistener (hg, "levelstepmode", @update_data); |
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 addlistener (hg, "labelspacing", @update_text); |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
182 addlistener (hg, "textlist", {@update_text, "textlist"}); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
183 addlistener (hg, "textlistmode", @update_text); |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
184 addlistener (hg, "textstep", {@update_text, "textstep"}); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
185 addlistener (hg, "textstepmode", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
186 addlistener (hg, "showtext", @update_text); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
187 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
188 addlistener (hg, "linecolor", @update_line); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
189 addlistener (hg, "linestyle", @update_line); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
190 addlistener (hg, "linewidth", @update_line); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
191 |
17167
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
192 ## Set axis before adding patches so that each new patch does not trigger |
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
193 ## new axis calculation. No need if mode is already "manual". |
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
194 if (all (strcmp (get (gca (), {"xlimmode", "ylimmode"}), "auto"))) |
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
195 axis ([min(x1(:)) max(x1(:)) min(y1(:)) max(y1(:))]); |
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
196 endif |
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
197 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
198 add_patch_children (hg); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
199 |
17167
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
200 if (! isempty (opts)) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
201 set (hg, opts{:}); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
202 endif |
17167
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
203 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
204 endfunction |
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 function add_patch_children (hg) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
207 c = get (hg, "contourmatrix"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
208 lev = get (hg, "levellist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
209 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
|
210 zlev = get (hg, "zlevel"); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
211 zmode = get (hg, "zlevelmode"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
212 lc = get (hg, "linecolor"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
213 lw = get (hg, "linewidth"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
214 ls = get (hg, "linestyle"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
215 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
|
216 ca = gca (); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
217 |
17411
f58ad514372c
__contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
218 ## Turn off automatic updating of clim while adding patches |
f58ad514372c
__contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
219 climmode = get (ca, "climmode"); |
f58ad514372c
__contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
220 set (ca, "climmode", "manual"); |
f58ad514372c
__contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
221 |
17466 | 222 if (strcmp (lc, "auto")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
223 lc = "flat"; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
224 endif |
7170 | 225 |
17466 | 226 if (strcmp (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
|
227 |
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
|
228 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
|
229 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
230 ## Decode contourc output format. |
17466 | 231 i = 1; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
232 ncont = 0; |
17466 | 233 while (i < columns (c)) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
234 ncont++; |
17466 | 235 cont_lev(ncont) = c(1, i); |
236 cont_len(ncont) = c(2, i); | |
237 cont_idx(ncont) = i+1; | |
238 ii = i + (1:cont_len(ncont)); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
239 cont_area(ncont) = polyarea (c(1, ii), c(2, ii)); |
17466 | 240 i += cont_len(ncont) + 1; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
241 endwhile |
7170 | 242 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
243 ## 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
|
244 ## 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
|
245 ## background colour. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
246 for k = 1:numel (lev) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
247 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
|
248 len = numel (lvl_idx); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
249 if (len > 1) |
10549 | 250 mark = false (size (lvl_idx)); |
251 a = 1; | |
252 while (a < len) | |
253 ## take 1st patch | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
254 pa_idx = lvl_idx(a); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
255 ## 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
|
256 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
|
257 curr_ct_len = cont_len(pa_idx); |
10549 | 258 ## get contour |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
259 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
|
260 b_vec = (a+1):len; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
261 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
|
262 in = inpolygon (next_ct_pt_vec(1,:), next_ct_pt_vec(2,:), |
10549 | 263 curr_ct(1, :), curr_ct(2, :)); |
17466 | 264 mark(b_vec(in)) = ! mark(b_vec(in)); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
265 a++; |
10549 | 266 endwhile |
267 if (numel (mark) > 0) | |
268 ## All marked contours describe a hole in a larger contour of | |
269 ## 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
|
270 ma_idx = lvl_idx(mark); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
271 if (k > 1) |
10549 | 272 ## Find color of level below. |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
273 tmp = find (abs (cont_lev - lev(k - 1)) < lvl_eps); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
274 lvl_bel_idx = tmp(1); |
10549 | 275 ## Set color of patches found. |
276 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
|
277 else |
10549 | 278 ## Set lowest level contour to NaN. |
279 cont_lev(ma_idx) = NaN; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
280 endif |
10549 | 281 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
282 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
283 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
284 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
285 ## 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
|
286 ## 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
|
287 del_idx = []; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
288 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
|
289 if (numel (max_idx) > 1) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
290 ## delete double entries |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
291 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
|
292 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
|
293 cont_len(del_idx) = cont_idx(del_idx) = []; |
7175 | 294 endif |
295 | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
296 ## 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
|
297 ## beginning with largest area. |
17466 | 298 [~, svec] = sort (cont_area); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
299 len = ncont - numel (del_idx); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
300 h = []; |
17466 | 301 for n = len:-1:1 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
302 idx = svec(n); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
303 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
|
304 if (all (ctmp(:,1) == ctmp(:,end))) |
17466 | 305 ## patch() doesn't need/want closed contour. It will do it itself. |
306 ctmp(:,end) = []; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
307 endif |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
308 if (isnan (cont_lev(idx))) |
13156
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
12648
diff
changeset
|
309 fc = get (ca, "color"); |
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
12648
diff
changeset
|
310 if (strcmp (fc, "none")) |
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
12648
diff
changeset
|
311 fc = get (ancestor (ca, "figure"), "color"); |
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
12648
diff
changeset
|
312 endif |
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
12648
diff
changeset
|
313 else |
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
12648
diff
changeset
|
314 fc = "flat"; |
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
12648
diff
changeset
|
315 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
316 h = [h; __go_patch__(ca, "xdata", ctmp(1, :)(:), "ydata", ctmp(2, :)(:), |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
317 "vertices", ctmp.', "faces", 1:(cont_len(idx)-1), |
17466 | 318 "facevertexcdata", cont_lev(idx), "facecolor", fc, |
319 "cdata", cont_lev(idx), "edgecolor", lc, | |
320 "linestyle", ls, "linewidth", lw, | |
321 "parent", hg)]; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
322 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
323 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
324 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
|
325 set (ca, "clim", [min(lev)-1, max(lev)+1], "layer", "top"); |
7170 | 326 else |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
327 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
|
328 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
329 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
330 ## Decode contourc output format. |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
331 h = []; |
17466 | 332 i = 1; |
333 while (i < length (c)) | |
334 clev = c(1,i); | |
335 clen = c(2,i); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
336 |
17466 | 337 if (all (c(:,i+1) == c(:,i+clen))) |
338 p = c(:, i+1:i+clen-1).'; | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
339 else |
17466 | 340 p = [c(:, i+1:i+clen), NaN(2, 1)].'; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
341 endif |
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 switch (zmode) |
10549 | 344 case "none" |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
345 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), |
17466 | 346 "zdata", [], |
347 "vertices", p, "faces", 1:rows (p), | |
348 "facevertexcdata", clev, "facecolor", "none", | |
349 "cdata", clev, "edgecolor", lc, | |
350 "linestyle", ls, "linewidth", lw, | |
351 "parent", hg)]; | |
10549 | 352 case "auto" |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
353 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), |
17466 | 354 "zdata", clev * ones (rows (p),1), |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
355 "vertices", [p, clev * ones(rows(p),1)], |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
356 "faces", 1:rows(p), |
17466 | 357 "facevertexcdata", clev, "facecolor", "none", |
358 "cdata", clev, "edgecolor", lc, | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
359 "linestyle", ls, "linewidth", lw, |
17466 | 360 "parent", hg)]; |
10549 | 361 otherwise |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
362 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), |
17466 | 363 "zdata", zlev * ones (rows (p), 1), |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
364 "vertices", [p, zlev * ones(rows(p),1)], |
17466 | 365 "faces", 1:rows (p), |
366 "facevertexcdata", clev, "facecolor", "none", | |
367 "cdata", clev, "edgecolor", lc, | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11163
diff
changeset
|
368 "linestyle", ls, "linewidth", lw, |
17466 | 369 "parent", hg)]; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
370 endswitch |
17466 | 371 i += clen + 1; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
372 endwhile |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
373 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
374 |
17411
f58ad514372c
__contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
375 set (ca, "climmode", climmode); |
f58ad514372c
__contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
376 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
377 endfunction |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
378 |
17466 | 379 function update_zlevel (h, ~) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
380 z = get (h, "zlevel"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
381 zmode = get (h, "zlevelmode"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
382 kids = get (h, "children"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
383 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
384 switch (zmode) |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
385 case "none" |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
386 set (kids, "zdata", []); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
387 case "auto" |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
388 for i = 1 : length (kids) |
17466 | 389 set (kids(i), "zdata", get (kids(i), "cdata") .* |
390 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
|
391 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
392 otherwise |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
393 for i = 1 : length (kids) |
17466 | 394 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
|
395 endfor |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
396 endswitch |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
397 endfunction |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
398 |
17466 | 399 function update_line (h, ~) |
9554
bda3513e7ba9
Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
400 lc = get (h, "linecolor"); |
17466 | 401 if (strcmp (lc, "auto")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
402 lc = "flat"; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
403 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
404 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
|
405 "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
|
406 endfunction |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
407 |
17466 | 408 function update_data (h, ~, prop = "") |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
409 persistent recursive = false; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
410 |
17466 | 411 if (! recursive) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
412 recursive = true; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
413 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
414 delete (get (h, "children")); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
415 |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16911
diff
changeset
|
416 switch (prop) |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17167
diff
changeset
|
417 case "levellist" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17167
diff
changeset
|
418 set (h, "levellistmode", "manual") |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17167
diff
changeset
|
419 case "levelstep" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17167
diff
changeset
|
420 set (h, "levelstepmode", "manual") |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
421 case "fill" |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
422 ## Switching from filled ('k' linespec) to unfilled, reset linecolor |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
423 if (strcmp (get (h, "fill"), "off")) |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
424 set (h, "linecolor", "auto"); |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
425 else |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
426 set (h, "linecolor", "black"); |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
427 endif |
16911 | 428 endswitch |
429 | |
17466 | 430 if (strcmp (get (h, "levellistmode"), "manual") |
16911 | 431 && ! strcmp (prop, "levelstep")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
432 lvl = get (h, "levellist"); |
17466 | 433 elseif (strcmp (get (h, "levelstepmode"), "manual")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
434 z = get (h, "zdata"); |
16911 | 435 lvs = get (h, "levelstep"); |
436 lvl(1) = ceil (min (z(:)) / lvs) * lvs; | |
437 lvl(2) = floor (max (z(:)) / lvs) * lvs; | |
438 if (lvl(1) >= lvl(2)) | |
439 lvl = median (z(:)); | |
440 else | |
441 lvl = lvl(1) : lvs : lvl(2); | |
442 endif | |
443 set (h, "levellist", lvl); | |
444 set (h, "levellistmode", "auto"); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
445 else |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
446 z = get (h, "zdata"); |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
447 ## FIXME: The levels should be determined similarly to {x,y,z}ticks |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
448 ## so that they aren't set at extremely odd values. |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
449 lvl = linspace (min (z(!isinf (z))), max (z(!isinf (z))), 10 + 2); |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
450 ## Strip off max outlier, min must stay for contourf hole algorithm. |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
451 lvl = lvl(1:end-1); |
7170 | 452 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
453 |
17466 | 454 if (strcmp (get (h, "fill"), "on")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
455 X = get (h, "xdata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
456 Y = get (h, "ydata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
457 Z = get (h, "zdata"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
458 if (isvector (X) || isvector (Y)) |
10549 | 459 [X, Y] = meshgrid (X, Y); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
460 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
461 [nr, nc] = size (Z); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
462 X0 = prepad (X, nc+1, 2 * X(1, 1) - X(1, 2), 2); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
463 X0 = postpad (X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
464 X0 = [X0(1, :); X0; X0(1, :)]; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
465 Y0 = prepad (Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
466 Y0 = postpad (Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1)); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
467 Y0 = [Y0(:, 1), Y0, Y0(:, 1)]; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
468 Z0 = -Inf (nr+2, nc+2); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
469 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
|
470 [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
|
471 else |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
472 [c, lev] = contourc (get (h, "xdata"), get (h, "ydata"), |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
473 get (h, "zdata"), lvl); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
474 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
475 set (h, "contourmatrix", c); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
476 |
17466 | 477 if (strcmp (get (h, "levellistmode"), "manual")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
478 ## Do nothing |
17466 | 479 elseif (strcmp (get (h, "levelstepmode"), "manual")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
480 set (h, "levellist", lev); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
481 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
482 set (h, "levellist", lev); |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
483 lvlstep = sum (diff (lvl)) / (length (lvl) - 1); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
484 set (h, "levelstep", lvlstep); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
485 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
486 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
487 add_patch_children (h); |
17474
6edc451629a6
__contour__.m: Ignore dummy input in all listener functions.
Rik <rik@octave.org>
parents:
17466
diff
changeset
|
488 update_text (h); |
16911 | 489 recursive = false; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
490 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
491 |
7170 | 492 endfunction |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
493 |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
494 function update_text (h, ~, prop = "") |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
495 persistent recursive = false; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
496 |
17466 | 497 if (! recursive) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
498 recursive = true; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
499 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
500 delete (findobj (h, "type", "text")); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
501 |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
502 switch (prop) |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
503 case "textlist" |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
504 set (h, "textlistmode", "manual") |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
505 case "textstep" |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
506 set (h, "textstepmode", "manual") |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
507 endswitch |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17474
diff
changeset
|
508 |
17466 | 509 if (strcmp (get (h, "textlistmode"), "manual")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
510 lvl = get (h, "textlist"); |
17466 | 511 elseif (strcmp (get (h, "textstepmode"), "manual")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
512 lev = get (h, "levellist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
513 |
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
|
514 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
|
515 |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
516 stp = get (h, "textstep"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
517 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
|
518 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
|
519 set (h, "textlist", lvl); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
520 else |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
521 lvl = get (h, "levellist"); |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
522 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
|
523 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
524 |
17466 | 525 if (strcmp (get (h, "showtext"), "on")) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
526 switch (get (h, "zlevelmode")) |
10549 | 527 case "manual" |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
528 __clabel__ (get (h, "contourmatrix"), lvl, h, |
10549 | 529 get (h, "labelspacing"), get (h, "zlevel")); |
530 case "auto" | |
531 __clabel__ (get (h, "contourmatrix"), lvl, h, | |
532 get (h, "labelspacing"), "auto"); | |
533 otherwise | |
534 __clabel__ (get (h, "contourmatrix"), lvl, h, | |
535 get (h, "labelspacing"), []); | |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
536 endswitch |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
537 endif |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11175
diff
changeset
|
538 |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11175
diff
changeset
|
539 recursive = false; |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
540 endif |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
541 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
|
542 |
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
|
543 function lvl_eps = get_lvl_eps (lev) |
17167
0a761f218d8d
Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
544 ## FIXME: is this the right thing to do for this tolerance? Should |
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
|
545 ## 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
|
546 ## 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
|
547 if (isscalar (lev)) |
12648
c6378cec77af
Fix unfilled contourf when lvl = [0,0] (bug #33177).
Marco Caliari marco.caliari@univr.it
parents:
11587
diff
changeset
|
548 lvl_eps = abs (lev) * sqrt (eps) + sqrt (eps); |
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
|
549 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
|
550 tmp = min (abs (diff (lev))); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
551 if (tmp < 10*eps) |
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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 endfunction |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
558 |