mosaic.contour#
- mosaic.contour(ax, *args, **kwargs)#
Plot contour lines on an unstructured MPAS mesh.
Call signature:
contour(ax, descriptor, Z, [levels], **kwargs)
contour()andcontourf()draw contour lines and filled contours respectively on an unstructured MPAS mesh. Except as noted, function signatures and return values are the same for both versions.- Parameters:
descriptor (
Descriptor) – MPAS mesh descriptor containing the unstructured grid connectivity and coordinate arraysZ (
array-like) – Scalar field defined at cell centers over which the contour is drawn. Color-mapping is controlled by cmap, norm, vmin, and vmax.levels (
intorarray-like, optional) – Determines the number and positions of the contour lines / regions.If an int n, use
MaxNLocator, which tries to automatically choose no more than n+2 “nice” contour level boundaries between the minimum and maximum values of Z.If array-like, draw contour lines at the specified levels. The values must be in increasing order.
If not given, a reasonable default is chosen automatically.
- Return type:
MPASContourSet- Other Parameters:
colors (color or
listof color, optional) – The colors of the levels, i.e. the lines formosaic.contourand the areas formosaic.contourf.The sequence is cycled for the levels in ascending order. If the sequence is shorter than the number of levels, it’s repeated.
As a shortcut, a single color may be used in place of one-element lists, i.e.
'red'instead of['red']to color all levels with the same color.By default (value None), the colormap specified by cmap will be used.
alpha (
float, default:1) – The alpha blending value, between 0 (transparent) and 1 (opaque).cmap (
stror ~matplotlib.colors.Colormap, default:rcParams[“image.cmap”](default:'viridis')) – The Colormap instance or registered colormap name used to map scalar data to colors.This parameter is ignored if colors is set.
norm (
stror ~matplotlib.colors.Normalize, optional) – The normalization method used to scale scalar data to the [0, 1] range before mapping to colors using cmap. By default, a linear scaling is used, mapping the lowest value to 0 and the highest to 1.If given, this can be one of the following:
An instance of .Normalize or one of its subclasses (see Colormap normalization).
A scale name, i.e. one of “linear”, “log”, “symlog”, “logit”, etc. For a list of available scales, call matplotlib.scale.get_scale_names(). In that case, a suitable .Normalize subclass is dynamically generated and instantiated.
This parameter is ignored if colors is set.
vmin, vmax (
float, optional) – When using scalar data and no explicit norm, vmin and vmax define the data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data. It is an error to use vmin/vmax when a norm instance is given (but using a str norm name together with vmin/vmax is acceptable).If vmin or vmax are not given, the default color scaling is based on levels.
This parameter is ignored if colors is set.
locator (
Locatorsubclass, optional) – The locator is used to determine the contour levels if they are not given explicitly via levels. Defaults to ~matplotlib.ticker.MaxNLocator.extend (
{'neither', 'both', 'min', 'max'}, default:'neither') – Determines the coloring of values that are outside the levels range.If ‘neither’, values outside the levels range are not colored. If ‘min’, ‘max’ or ‘both’, color the values below, above or below and above the levels range.
Values below
min(levels)and abovemax(levels)are mapped to the under/over values of the .Colormap. Note that most colormaps do not have dedicated colors for these by default, so that the over and under values are the edge values of the colormap. You may want to set these values explicitly using .Colormap.set_under and .Colormap.set_over.linewidths (
floatorarray-like, default:rcParams[“contour.linewidth”](default:None)) – Only applies tocontour().The line width of the contour lines.
If a number, all levels will be plotted with this linewidth.
If a sequence, the levels in ascending order will be plotted with the linewidths in the order specified.
If None, this falls back to
rcParams[“lines.linewidth”](default:1.5).linestyles (
{*None*, 'solid', 'dashed', 'dashdot', 'dotted'}, optional) – Only applies tocontour().If linestyles is None, the default is ‘solid’ unless the lines are monochrome. In that case, negative contours will instead take their linestyle from the negative_linestyles argument.
linestyles can also be an iterable of the above strings specifying a set of linestyles to be used. If this iterable is shorter than the number of contour levels it will be repeated as necessary.
negative_linestyles (
{*None*, 'solid', 'dashed', 'dashdot', 'dotted'}, optional) – Only applies tocontour().If linestyles is None and the lines are monochrome, this argument specifies the line style for negative contours.
If negative_linestyles is None, the default is taken from
rcParams[“contour.negative_linestyle”](default:'dashed').hatches (
list[str], optional) – Only applies tocontourf().A list of cross hatch patterns to use on the filled areas. If None, no hatching will be added to the contour. See .Patch.set_hatch for pattern syntax.
antialiased (
bool, optional) – Enable antialiasing, overriding the defaults. For filled contours, the default is False. For line contours, it is taken fromrcParams[“lines.antialiased”](default:True).
Notes
mosaic.contourfdoes not draw polygon edges. To draw edges, add line contours with calls to mosaic.contour.mosaic.contourffills intervals that are closed at the top; that is, for boundaries z1 and z2, the filled region is:z1 < Z <= z2
except for the lowest interval, which is closed on both sides (i.e. it includes the lowest value).
Contouring is performed directly on the MPAS unstructured mesh by traversing the dual graph of cell edges, without any intermediate grid interpolation.