Function Reference
— Function File: [c, h] = contourf (x, y, z, lvl)
— Function File: [c, h] = contourf (x, y, z, n)
— Function File: [c, h] = contourf (x, y, z)
— Function File: [c, h] = contourf (z, n)
— Function File: [c, h] = contourf (z, lvl)
— Function File: [c, h] = contourf (z)
— Function File: [c, h] = contourf (ax, ...)
— Function File: [c, h] = contourf (..., "property", val)

Compute and plot filled contours of the matrix z. Parameters x, y and n or lvl are optional.

The return value c is a 2xn matrix containing the contour lines as described in the help to the contourc function.

The return value h is handle-vector to the patch objects creating the filled contours.

If x and y are ommited they are taken as the row/column index of z. n is a scalar denoting the number of lines to compute. Alternatively lvl is a vector containing the contour levels. If only one value (e.g. lvl0) is wanted, set lvl to [lvl0, lvl0]. If both n or lvl are omitted a default value of 10 contour level is assumed.

If provided, the filled contours are added to the axes object ax instead of the current axis.

The following example plots filled contours of the peaks function.

          [x, y, z] = peaks (50);
          contourf (x, y, z, -7:9)

See also: contour contourc patch

Demonstration 1

The following code

 [x, y, z] = peaks (50);
 contourf (x, y, z, -7:9)

Produces the following figure

Demonstration 2

The following code

 [theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64));
 [X, Y] = pol2cart (theta, r);
 Z = sin(2*theta).*(1-r);
 contourf(X, Y, abs(Z), 10)

Produces the following figure