7110
|
1 ## Copyright (C) 2007 Kai Habel |
7109
|
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 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} pcolor (@var{x}, @var{y}, @var{c}) |
|
21 ## @deftypefnx {Function File} {} pcolor (@var{c}) |
|
22 ## Density plot for given matrices @var{x}, and @var{y} from @code{meshgrid} and |
|
23 ## a matrix @var{c} corresponding to the @var{x} and @var{y} coordinates of |
|
24 ## the mesh. If @var{x} and @var{y} are vectors, then a typical vertex |
|
25 ## is (@var{x}(j), @var{y}(i), @var{c}(i,j)). Thus, columns of @var{c} |
|
26 ## correspond to different @var{x} values and rows of @var{c} correspond |
|
27 ## to different @var{y} values. |
|
28 ## @seealso{meshgrid, contour} |
|
29 ## @end deftypefn |
|
30 |
7110
|
31 ## Author: Kai Habel <kai.habel@gmx.de> |
7109
|
32 |
7110
|
33 function h = pcolor (x, y, c) |
7109
|
34 |
|
35 newplot (); |
|
36 |
|
37 if (nargin == 1) |
7110
|
38 c = x; |
7337
|
39 [nr, nc] = size(c); |
|
40 z = zeros (nr, nc); |
|
41 [x, y] = meshgrid (1:nc, 1:nr); |
7109
|
42 elseif (nargin == 3) |
7110
|
43 z = zeros (size (c)); |
7109
|
44 else |
7110
|
45 print_usage (); |
|
46 endif |
7109
|
47 |
7146
|
48 tmp = surface (x, y, z, c); |
7109
|
49 |
7110
|
50 ax = get (tmp, "parent"); |
|
51 |
|
52 set (tmp, "facecolor", "flat"); |
7271
|
53 set (ax, "box", "on"); |
7146
|
54 |
|
55 if (! ishold ()) |
|
56 set (ax, "view", [0, 90]); |
|
57 endif |
7110
|
58 |
7109
|
59 if (nargout > 0) |
|
60 h = tmp; |
|
61 endif |
|
62 |
|
63 endfunction |