Navigation

Operators and Keywords

Function List:

C++ API

: pcolor (x, y, c)
: pcolor (c)
: pcolor (hax, …)
: h = pcolor (…)

Produce a 2-D density plot.

A pcolor plot draws rectangles with colors from the matrix c over the two-dimensional region represented by the matrices x and y. x and y are the coordinates of the mesh’s vertices and are typically the output of meshgrid. If x and y are vectors, then a typical vertex is (x(j), y(i), c(i,j)). Thus, columns of c correspond to different x values and rows of c correspond to different y values.

The values in c are scaled to span the range of the current colormap. Limits may be placed on the color axis by the command caxis, or by setting the clim property of the parent axis.

The face color of each cell of the mesh is determined by interpolating the values of c for each of the cell’s vertices; Contrast this with imagesc which renders one cell for each element of c.

shading modifies an attribute determining the manner by which the face color of each cell is interpolated from the values of c, and the visibility of the cells’ edges. By default the attribute is "faceted", which renders a single color for each cell’s face with the edge visible.

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

The optional return value h is a graphics handle to the created surface object.

See also: caxis, shading, meshgrid, contour, imagesc.

Demonstration 1

The following code

 clf;
 colormap ("default");
 Z = peaks ();
 pcolor (Z);
 title ("pcolor() of peaks with facet shading");

Produces the following figure

Figure 1

Demonstration 2

The following code

 clf;
 colormap ("default");
 [X,Y,Z] = sombrero ();
 [Fx,Fy] = gradient (Z);
 pcolor (X,Y,Fx+Fy);
 shading interp;
 axis tight;
 title ("pcolor() of peaks with interp shading");

Produces the following figure

Figure 1

Package: octave