Mercurial > hg > octave-nkf
annotate scripts/plot/pcolor.m @ 14237:11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Add clf() to all demos using plot features to get reproducibility.
Use 64 as input to all colormaps (jet (64)) to get reproducibility.
* bicubic.m, cell2mat.m, celldisp.m, cplxpair.m, interp1.m, interp2.m,
interpft.m, interpn.m, profile.m, profshow.m, convhull.m, delaunay.m,
griddata.m, inpolygon.m, voronoi.m, autumn.m, bone.m, contrast.m, cool.m,
copper.m, flag.m, gmap40.m, gray.m, hot.m, hsv.m, image.m, imshow.m, jet.m,
ocean.m, pink.m, prism.m, rainbow.m, spring.m, summer.m, white.m, winter.m,
condest.m, onenormest.m, axis.m, clabel.m, colorbar.m, comet.m, comet3.m,
compass.m, contour.m, contour3.m, contourf.m, cylinder.m, daspect.m,
ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m,
ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m,
fplot.m, grid.m, hold.m, isosurface.m, legend.m, loglog.m, loglogerr.m,
pareto.m, patch.m, pbaspect.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m,
plotyy.m, polar.m, quiver.m, quiver3.m, rectangle.m, refreshdata.m, ribbon.m,
rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m,
semilogyerr.m, shading.m, slice.m, sombrero.m, stairs.m, stem.m, stem3.m,
subplot.m, surf.m, surfc.m, surfl.m, surfnorm.m, text.m, title.m, trimesh.m,
triplot.m, trisurf.m, uigetdir.m, uigetfile.m, uimenu.m, uiputfile.m,
waitbar.m, xlim.m, ylim.m, zlim.m, mkpp.m, pchip.m, polyaffine.m, spline.m,
bicgstab.m, cgs.m, gplot.m, pcg.m, pcr.m, treeplot.m, strtok.m, demo.m,
example.m, rundemos.m, speed.m, test.m, calendar.m, datestr.m, datetick.m,
weekday.m: Revamp %!demos to use Octave coding conventions on spacing, etc.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 20 Jan 2012 12:59:53 -0800 |
parents | 72c96de7a403 |
children | c4fa5e0b6193 |
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 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 -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
20 ## @deftypefn {Function File} {} pcolor (@var{x}, @var{y}, @var{c}) |
7109 | 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 | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
24 ## the mesh's vertices. If @var{x} and @var{y} are vectors, then a typical |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
25 ## vertex |
7109 | 26 ## is (@var{x}(j), @var{y}(i), @var{c}(i,j)). Thus, columns of @var{c} |
27 ## correspond to different @var{x} values and rows of @var{c} correspond | |
28 ## to different @var{y} values. | |
8132
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
29 ## |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
30 ## 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
|
31 ## 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
|
32 ## 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
|
33 ## parent axis. |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
34 ## |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
35 ## The face color of each cell of the mesh is determined by interpolating |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
36 ## the values of @var{c} for the cell's vertices. Contrast this with |
8132
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
37 ## @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
|
38 ## |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
39 ## @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
|
40 ## face color of each cell is interpolated from the values of @var{c}, |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
41 ## and the visibility of the cells' edges. By default the attribute is |
8132
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
42 ## "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
|
43 ## visible. |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
44 ## |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
45 ## @var{h} is the handle to the surface object. |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
46 ## |
8139ddb83bc3
pcolor.m: Improve doc strings.
Ben Abbott <bpabbott@mac.com>
parents:
7337
diff
changeset
|
47 ## @seealso{caxis, contour, meshgrid, imagesc, shading} |
7109 | 48 ## @end deftypefn |
49 | |
7110 | 50 ## Author: Kai Habel <kai.habel@gmx.de> |
7109 | 51 |
7110 | 52 function h = pcolor (x, y, c) |
7109 | 53 |
54 newplot (); | |
55 | |
56 if (nargin == 1) | |
7110 | 57 c = x; |
7337 | 58 [nr, nc] = size(c); |
59 z = zeros (nr, nc); | |
60 [x, y] = meshgrid (1:nc, 1:nr); | |
7109 | 61 elseif (nargin == 3) |
7110 | 62 z = zeros (size (c)); |
7109 | 63 else |
7110 | 64 print_usage (); |
65 endif | |
7109 | 66 |
7146 | 67 tmp = surface (x, y, z, c); |
7109 | 68 |
7110 | 69 ax = get (tmp, "parent"); |
70 | |
71 set (tmp, "facecolor", "flat"); | |
7271 | 72 set (ax, "box", "on"); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
73 |
7146 | 74 if (! ishold ()) |
75 set (ax, "view", [0, 90]); | |
76 endif | |
7110 | 77 |
7109 | 78 if (nargout > 0) |
79 h = tmp; | |
80 endif | |
81 | |
82 endfunction | |
12817
e3e6079039c6
codesprint: 2 demos for pcolor.m dummy for surface.m
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
83 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
84 |
12817
e3e6079039c6
codesprint: 2 demos for pcolor.m dummy for surface.m
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
85 %!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
|
86 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
87 %! [~,~,Z] = peaks (); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
88 %! pcolor (Z); |
12817
e3e6079039c6
codesprint: 2 demos for pcolor.m dummy for surface.m
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
89 |
e3e6079039c6
codesprint: 2 demos for pcolor.m dummy for surface.m
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
90 %!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
|
91 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
92 %! [X,Y,Z] = sombrero (); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
93 %! [Fx,Fy] = gradient (Z); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
94 %! pcolor (X,Y,Fx+Fy); |
12817
e3e6079039c6
codesprint: 2 demos for pcolor.m dummy for surface.m
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
95 %! shading interp; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
96 |