FUNCTION REFERENCE

contour

Contour lines of a matrix.

Contour lines of a matrix.

Syntax

contour(Z)

Syntax

contour(X, Y, Z)

Syntax

contour(..., n)

Syntax

contour(..., v)

Syntax

contour(..., LineSpec)

Syntax

contour(..., Name, Value)

Syntax

contour(ax, ...)

Syntax

[C, h] = contour(...)

Draws the contour lines of contourc (same inputs, level rule and C layout): one line object per level, coloured from the axes colormap at that level. When the axes colour limits are automatic, contour sets CLim to [min max] of the levels of all contours on the axes ([k-1 k+1] for a single level), so colorbar shows the levels; with hold on a second contour shares that scale and the earlier ones are redrawn with it. A CLim you set yourself (clim([a b]), set CLim) is kept. A colour in LineSpec or LineColor/EdgeColor draws every level in that colour. Options: LineColor/EdgeColor (a colour, 'flat' or 'none'), LineWidth (default 0.5), LineStyle ('-', '--', ':', '-.' or 'none'; 'none' hides the lines and leaves LineColor as it is), LevelList (the levels), LevelStep (spacing between levels), FaceAlpha (fill opacity in [0,1]), ShowText ('on' writes the level, as %g, at the midpoint of every line, in the axes font size) and DisplayName. get, set and dot syntax on h support LevelList, LevelStep, LineColor, EdgeColor, LineWidth, LineStyle, FaceAlpha, ShowText, ZData and Visible (each set redraws the contour; the labels follow Visible); Fill ('off') and Type ('contour') are read-only; ContourMatrix, XData and YData can be read.

Example

[C, h] = contour(peaks(20)); h.Type   % 'contour'

Example

[~, h] = contour(peaks(20), [-2 0 2], 'k--'); get(h, 'LevelList')   % [-2 0 2]

Example

[~, h] = contour(peaks(20)); set(h, 'LevelList', [0 1]); h.LevelList   % [0 1]

Example

contour(peaks(20), 'ShowText', 'on'); colorbar;

Differences from MATLAB: the level rule and line order are GNU Octave's (Octave's contour also lists min(Z) first in LevelList, a level that never has a line; matrust lists the drawn levels only); the line colours are fixed when the contour is drawn (a later colormap call does not recolour them) and CLimMode reads 'manual' after contour set the limits (so clim('manual') straight after a contour still counts as automatic until you give other limits). One legend entry per contour. At most 64 series per axes (one per level with lines), 1000000 line points per figure and 256 labels per axes. A saved .mrfig holds the drawn lines and bands, not a contour object: reopening shows the same lines and fills, but the reopened objects are plain lines and patches (no LevelList), and labels are left out because .mrfig does not store axes text objects yet. No 3-D contours (contour3), fcontour, LabelSpacing or label gaps in the lines.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.