Skip to content

contour

Contour plot of a 2D scalar field.

[C, h] = contour(Z)
[C, h] = contour(Z, n)
[C, h] = contour(X, Y, Z, ...)

Draws contour lines of Z over the (X, Y) grid. With n (integer), draws n automatically-chosen levels; with a vector of values, draws contours at those levels exactly.

[X, Y] = meshgrid(-2:0.1:2);
Z = X.*exp(-X.^2 - Y.^2);
contour(X, Y, Z, 20)
  • contourf — Filled contour plot.
  • contour3 — 3D contour plot.
  • contourslice — Contour slices through a 3D volume.
  • mesh — 3D mesh (wireframe) plot.
  • surf — 3D surface plot with colored faces.