Skip to content

plot_contour

plot_contour(x, y, field, *, field_name='field', levels=50, figsize=(10, 6), title=None, filename=None, show=True)

Plot a filled contour of a scalar field on a structured grid.

Parameters:

Name Type Description Default
x ndarray

x-coordinates, shape (ni, nj) or (ni, nj, 1).

required
y ndarray

y-coordinates, same shape as x.

required
field ndarray

Scalar field data, same shape as x.

required
field_name str

Label for the colorbar.

'field'
levels int

Number of contour levels.

50
figsize tuple[float, float]

Figure size (width, height) in inches.

(10, 6)
title str | None

Plot title. Defaults to the field name.

None
filename str | None

If given, save the figure to this path.

None
show bool

Whether to call plt.show().

True

Returns:

Type Description
Figure

The matplotlib Figure.