xarray.plot.imshow

xarray.plot.imshow(x, y, z, ax, **kwargs)

Image plot of 2d DataArray using matplotlib.pyplot

Wraps matplotlib.pyplot.imshow()

While other plot methods require the DataArray to be strictly two-dimensional, imshow also accepts a 3D array where some dimension can be interpreted as RGB or RGBA color channels and allows this dimension to be specified via the kwarg rgb=.

Unlike matplotlib, Xarray can apply vmin and vmax to RGB or RGBA data, by applying a single scaling factor and offset to all bands. Passing robust=True infers vmin and vmax in the usual way.

Note

This function needs uniformly spaced coordinates to properly label the axes. Call DataArray.plot() to check.

The pixels are centered on the coordinates values. Ie, if the coordinate value is 3.2 then the pixels for those coordinates will be centered on 3.2.

Parameters
darrayDataArray

Must be 2 dimensional, unless creating faceted plots

xstring, optional

Coordinate for x axis. If None use darray.dims[1]

ystring, optional

Coordinate for y axis. If None use darray.dims[0]

figsizetuple, optional

A tuple (width, height) of the figure in inches. Mutually exclusive with size and ax.

aspectscalar, optional

Aspect ratio of plot, so that aspect * size gives the width in inches. Only used if a size is provided.

sizescalar, optional

If provided, create a new figure for the plot with the given size. Height (in inches) of each plot. See also: aspect.

axmatplotlib axes object, optional

Axis on which to plot this figure. By default, use the current axis. Mutually exclusive with size and figsize.

rowstring, optional

If passed, make row faceted plots on this dimension name

colstring, optional

If passed, make column faceted plots on this dimension name

col_wrapinteger, optional

Use together with col to wrap faceted plots

xscale, yscale‘linear’, ‘symlog’, ‘log’, ‘logit’, optional

Specifies scaling for the x- and y-axes respectively

xticks, yticksSpecify tick locations for x- and y-axes
xlim, ylimSpecify x- and y-axes limits
xincreaseNone, True, or False, optional

Should the values on the x axes be increasing from left to right? if None, use the default for the matplotlib function.

yincreaseNone, True, or False, optional

Should the values on the y axes be increasing from top to bottom? if None, use the default for the matplotlib function.

add_colorbarBoolean, optional

Adds colorbar to axis

add_labelsBoolean, optional

Use xarray metadata to label axes

normmatplotlib.colors.Normalize instance, optional

If the norm has vmin or vmax specified, the corresponding kwarg must be None.

vmin, vmaxfloats, optional

Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments. When a diverging dataset is inferred, setting one of these values will fix the other by symmetry around center. Setting both values prevents use of a diverging colormap. If discrete levels are provided as an explicit list, both of these values are ignored.

cmapmatplotlib colormap name or object, optional

The mapping from data values to color space. If not provided, this will be either be viridis (if the function infers a sequential dataset) or RdBu_r (if the function infers a diverging dataset). When Seaborn is installed, cmap may also be a seaborn color palette. If cmap is seaborn color palette and the plot type is not contour or contourf, levels must also be specified.

colorsdiscrete colors to plot, optional

A single color or a list of colors. If the plot type is not contour or contourf, the levels argument is required.

centerfloat, optional

The value at which to center the colormap. Passing this value implies use of a diverging colormap. Setting it to False prevents use of a diverging colormap.

robustbool, optional

If True and vmin or vmax are absent, the colormap range is computed with 2nd and 98th percentiles instead of the extreme values.

extend{‘neither’, ‘both’, ‘min’, ‘max’}, optional

How to draw arrows extending the colorbar beyond its limits. If not provided, extend is inferred from vmin, vmax and the data limits.

levelsint or list-like object, optional

Split the colormap (cmap) into discrete color intervals. If an integer is provided, “nice” levels are chosen based on the data range: this can imply that the final number of levels is not exactly the expected one. Setting vmin and/or vmax with levels=N is equivalent to setting levels=np.linspace(vmin, vmax, N).

infer_intervalsbool, optional

Only applies to pcolormesh. If True, the coordinate intervals are passed to pcolormesh. If False, the original coordinates are used (this can be useful for certain map projections). The default is to always infer intervals, unless the mesh is irregular and plotted on a map projection.

subplot_kwsdict, optional

Dictionary of keyword arguments for matplotlib subplots. Only applies to FacetGrid plotting.

cbar_axmatplotlib Axes, optional

Axes in which to draw the colorbar.

cbar_kwargsdict, optional

Dictionary of keyword arguments to pass to the colorbar.

**kwargsoptional

Additional arguments to wrapped matplotlib function

Returns
artist :

The same type of primitive artist that the wrapped matplotlib function returns