annotate scripts/plot/draw/triplot.m @ 19016:87c3848cf3c0

Fix bug when hggroup used with primitive graphic object (bug #42532). * image.m, text.m, line.m, patch.m: __plt_get_axis_arg__ will return axis and hggroup when 'parent' property is used. Select the first returned object which is the axes, rather than passing both axis and hggroup to further plot subroutines.
author Rik <rik@octave.org>
date Tue, 10 Jun 2014 14:03:09 -0700
parents d63878346099
children 446c46af4b42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17572
diff changeset
1 ## Copyright (C) 2007-2013 David Bateman
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
2 ##
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
3 ## This file is part of Octave.
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
4 ##
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6826
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6826
diff changeset
8 ## your option) any later version.
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
9 ##
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
13 ## General Public License for more details.
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
14 ##
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6826
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6826
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
18
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} triplot (@var{tri}, @var{x}, @var{y})
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
21 ## @deftypefnx {Function File} {} triplot (@var{tri}, @var{x}, @var{y}, @var{linespec})
7650
eb7bdde776f2 Texinfo fixes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
22 ## @deftypefnx {Function File} {@var{h} =} triplot (@dots{})
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
23 ## Plot a 2-D triangular mesh.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
24 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
25 ## @var{tri} is typically the output of a Delaunay triangulation over the
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
26 ## grid of @var{x}, @var{y}. Every row of @var{tri} represents one triangle
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
27 ## and contains three indices into [@var{x}, @var{y}] which are the
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
28 ## vertices of the triangles in the x-y plane.
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 13747
diff changeset
29 ##
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
30 ## The linestyle to use for the plot can be defined with the argument
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
31 ## @var{linespec} of the same format as the @code{plot} command.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
32 ##
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
33 ## The optional return value @var{h} is a graphics handle to the created
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 14245
diff changeset
34 ## patch object.
12187
87926ee23581 Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
35 ## @seealso{plot, trimesh, trisurf, delaunay}
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
36 ## @end deftypefn
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
37
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
38 function h = triplot (tri, x, y, varargin)
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
39
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
40 if (nargin < 3)
6826
8618f29520c6 [project @ 2007-08-24 16:02:07 by jwe]
jwe
parents: 6823
diff changeset
41 print_usage ();
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
42 endif
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
43
6826
8618f29520c6 [project @ 2007-08-24 16:02:07 by jwe]
jwe
parents: 6823
diff changeset
44 idx = tri(:, [1, 2, 3, 1]).';
13747
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
45 nt = rows (tri);
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
46 handle = plot ([x(idx); NaN(1, nt)](:),
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
47 [y(idx); NaN(1, nt)](:), varargin{:});
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
48
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
49 if (nargout > 0)
13747
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
50 h = handle;
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
51 endif
13747
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
52
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
53 endfunction
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
54
13747
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
55
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
56 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
57 %! clf;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
58 %! old_state = rand ('state');
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
59 %! restore_state = onCleanup (@() rand ('state', old_state));
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
60 %! rand ('state', 2);
13747
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
61 %! N = 20;
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
62 %! x = rand (N, 1);
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
63 %! y = rand (N, 1);
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
64 %! tri = delaunay (x, y);
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents:
diff changeset
65 %! triplot (tri, x, y);
13747
e8564e8b0043 Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents: 12792
diff changeset
66