annotate scripts/plot/pcolor.m @ 8920:eb63fbe60fab

update copyright notices
author John W. Eaton <jwe@octave.org>
date Sat, 07 Mar 2009 10:41:27 -0500
parents 8139ddb83bc3
children dbd0c77e575e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8132
diff changeset
1 ## Copyright (C) 2007, 2008 Kai Habel
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
2 ##
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
4 ##
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
9 ##
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
14 ##
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
18
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {} pcolor (@var{x}, @var{y}, @var{c})
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefnx {Function File} {} pcolor (@var{c})
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
22 ## Density plot for given matrices @var{x}, and @var{y} from @code{meshgrid} and
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
23 ## a matrix @var{c} corresponding to the @var{x} and @var{y} coordinates of
8132
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
24 ## the mesh's vertices. If @var{x} and @var{y} are vectors, then a typical vertex
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
25 ## is (@var{x}(j), @var{y}(i), @var{c}(i,j)). Thus, columns of @var{c}
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
26 ## correspond to different @var{x} values and rows of @var{c} correspond
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
27 ## to different @var{y} values.
8132
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
28 ##
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
29 ## The @code{colormap} is scaled to the extents of @var{c}.
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
30 ## Limits may be placed on the color axis by the
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
31 ## command @code{caxis}, or by setting the @code{clim} property of the
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
32 ## parent axis.
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
33 ##
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
34 ## The face color of each cell of the mesh is determined by interpolating
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
35 ## the values of @var{c} for the cell's vertices. Contrast this with
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
36 ## @code{imagesc} which renders one cell for each element of @var{c}.
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
37 ##
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
38 ## @code{shading} modifies an attribute determining the manner by which the
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
39 ## face color of each cell is interpolated from the values of @var{c},
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
40 ## and the visibility of the cells' edges. By default the attribute is
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
41 ## "faceted", which renders a single color for each cell's face with the edge
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
42 ## visible.
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
43 ##
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
44 ## @var{h} is the handle to the surface object.
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
45 ##
8139ddb83bc3 pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents: 7337
diff changeset
46 ## @seealso{caxis, contour, meshgrid, imagesc, shading}
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
47 ## @end deftypefn
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
48
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
49 ## Author: Kai Habel <kai.habel@gmx.de>
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
50
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
51 function h = pcolor (x, y, c)
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
52
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
53 newplot ();
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
54
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
55 if (nargin == 1)
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
56 c = x;
7337
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents: 7271
diff changeset
57 [nr, nc] = size(c);
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents: 7271
diff changeset
58 z = zeros (nr, nc);
e70789e0cd92 [project @ 2007-12-28 21:04:44 by jwe]
jwe
parents: 7271
diff changeset
59 [x, y] = meshgrid (1:nc, 1:nr);
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
60 elseif (nargin == 3)
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
61 z = zeros (size (c));
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
62 else
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
63 print_usage ();
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
64 endif
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
65
7146
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents: 7110
diff changeset
66 tmp = surface (x, y, z, c);
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
67
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
68 ax = get (tmp, "parent");
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
69
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
70 set (tmp, "facecolor", "flat");
7271
c18512d0ddb6 [project @ 2007-12-10 06:52:51 by jwe]
jwe
parents: 7146
diff changeset
71 set (ax, "box", "on");
7146
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents: 7110
diff changeset
72
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents: 7110
diff changeset
73 if (! ishold ())
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents: 7110
diff changeset
74 set (ax, "view", [0, 90]);
c7e5e638a8d0 [project @ 2007-11-09 17:49:44 by jwe]
jwe
parents: 7110
diff changeset
75 endif
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
76
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
77 if (nargout > 0)
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
78 h = tmp;
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
79 endif
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
80
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
81 endfunction