Mercurial > hg > octave-lyh
annotate scripts/plot/triplot.m @ 17475:fd01c78caa0b
Added tag ss-3-7-7 for changeset cc13924a4266
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 23 Sep 2013 13:31:11 -0400 |
parents | eaab03308c0b |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2007-2012 David Bateman |
6823 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6823 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6823 | 18 |
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 | 21 ## @deftypefnx {Function File} {} triplot (@var{tri}, @var{x}, @var{y}, @var{linespec}) |
7650 | 22 ## @deftypefnx {Function File} {@var{h} =} triplot (@dots{}) |
17126
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 ## |
17126
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 | 36 ## @end deftypefn |
37 | |
38 function h = triplot (tri, x, y, varargin) | |
39 | |
40 if (nargin < 3) | |
6826 | 41 print_usage (); |
6823 | 42 endif |
43 | |
6826 | 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 | 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 | 51 endif |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
52 |
6823 | 53 endfunction |
54 | |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
55 |
6823 | 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 | 64 %! tri = delaunay (x, y); |
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 |