xarray.plot.pcolormesh (2024)

xarray.plot.pcolormesh(darray, *args, x=None, y=None, figsize=None, size=None, aspect=None, ax=None, row=None, col=None, col_wrap=None, xincrease=True, yincrease=True, add_colorbar=None, add_labels=True, vmin=None, vmax=None, cmap=None, center=None, robust=False, extend=None, levels=None, infer_intervals=None, colors=None, subplot_kws=None, cbar_ax=None, cbar_kwargs=None, xscale=None, yscale=None, xticks=None, yticks=None, xlim=None, ylim=None, norm=None, **kwargs)[source]#

Pseudocolor plot of 2D DataArray.

Wraps matplotlib.pyplot.pcolormesh().

Parameters:
  • darray (DataArray) – Must be two-dimensional, unless creating faceted plots.

  • x (Hashable or None, optional) – Coordinate for x axis. If None, use darray.dims[1].

  • y (Hashable or None, optional) – Coordinate for y axis. If None, use darray.dims[0].

  • figsize (Iterable or float or None, optional) – A tuple (width, height) of the figure in inches.Mutually exclusive with size and ax.

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

  • aspect ("auto", "equal", scalar or None, optional) – Aspect ratio of plot, so that aspect * size gives the width ininches. Only used if a size is provided.

  • ax (matplotlib axes object, optional) – Axes on which to plot. By default, use the current axes.Mutually exclusive with size and figsize.

  • row (Hashable or None, optional) – If passed, make row faceted plots on this dimension name.

  • col (Hashable or None, optional) – If passed, make column faceted plots on this dimension name.

  • col_wrap (int, optional) – Use together with col to wrap faceted plots.

  • xincrease (None, True, or False, optional) – Should the values on the x axis be increasing from left to right?If None, use the default for the Matplotlib function.

  • yincrease (None, True, or False, optional) – Should the values on the y axis be increasing from top to bottom?If None, use the default for the Matplotlib function.

  • add_colorbar (bool, optional) – Add colorbar to axes.

  • add_labels (bool, optional) – Use xarray metadata to label axes.

  • vmin (float or None, optional) – Lower value to anchor the colormap, otherwise it is inferred from thedata and other keyword arguments. When a diverging dataset is inferred,setting vmin or vmax will fix the other by symmetry aroundcenter. Setting both values prevents use of a diverging colormap.If discrete levels are provided as an explicit list, both of thesevalues are ignored.

  • vmax (float or None, optional) – Upper value to anchor the colormap, otherwise it is inferred from thedata and other keyword arguments. When a diverging dataset is inferred,setting vmin or vmax will fix the other by symmetry aroundcenter. Setting both values prevents use of a diverging colormap.If discrete levels are provided as an explicit list, both of thesevalues are ignored.

  • cmap (matplotlib colormap name or colormap, optional) – The mapping from data values to color space. If not provided, thiswill be either be 'viridis' (if the function infers a sequentialdataset) or 'RdBu_r' (if the function infers a diverging dataset).See Choosing Colormaps in Matplotlibfor more information.

    If seaborn is installed, cmap may also be aseaborn color palette.Note: if cmap is a seaborn color palette and the plot typeis not 'contour' or 'contourf', levels must also be specified.

  • center (float or False, optional) – The value at which to center the colormap. Passing this value impliesuse of a diverging colormap. Setting it to False prevents use of adiverging colormap.

  • robust (bool, optional) – If True and vmin or vmax are absent, the colormap range iscomputed 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 notprovided, extend is inferred from vmin, vmax and the data limits.

  • levels (int or array-like, optional) – Split the colormap (cmap) into discrete color intervals. If an integeris provided, “nice” levels are chosen based on the data range: this canimply that the final number of levels is not exactly the expected one.Setting vmin and/or vmax with levels=N is equivalent tosetting levels=np.linspace(vmin, vmax, N).

  • infer_intervals (bool, optional) – Only applies to pcolormesh. If True, the coordinate intervals arepassed to pcolormesh. If False, the original coordinates are used(this can be useful for certain map projections). The default is toalways infer intervals, unless the mesh is irregular and plotted ona map projection.

  • colors (str or array-like of color-like, optional) – A single color or a sequence of colors. If the plot type is not 'contour'or 'contourf', the levels argument is required.

  • subplot_kws (dict, optional) – Dictionary of keyword arguments for Matplotlib subplots. Only usedfor 2D and faceted plots.(see matplotlib.figure.Figure.add_subplot()).

  • cbar_ax (matplotlib axes object, optional) – Axes in which to draw the colorbar.

  • cbar_kwargs (dict, optional) – Dictionary of keyword arguments to pass to the colorbar(see matplotlib.figure.Figure.colorbar()).

  • xscale ({'linear', 'symlog', 'log', 'logit'} or None, optional) – Specifies scaling for the x-axes.

  • yscale ({'linear', 'symlog', 'log', 'logit'} or None, optional) – Specifies scaling for the y-axes.

  • xticks (ArrayLike or None, optional) – Specify tick locations for x-axes.

  • yticks (ArrayLike or None, optional) – Specify tick locations for y-axes.

  • xlim (tuple[float, float] or None, optional) – Specify x-axes limits.

  • ylim (tuple[float, float] or None, optional) – Specify y-axes limits.

  • norm (matplotlib.colors.Normalize, optional) – If norm has vmin or vmax specified, the correspondingkwarg must be None.

  • **kwargs (optional) – Additional keyword arguments to wrapped Matplotlib function.

Returns:

artist – The same type of primitive artist that the wrapped Matplotlibfunction returns.

Contents

xarray.plot.pcolormesh (2024)
Top Articles
Latest Posts
Article information

Author: Terence Hammes MD

Last Updated:

Views: 5541

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Terence Hammes MD

Birthday: 1992-04-11

Address: Suite 408 9446 Mercy Mews, West Roxie, CT 04904

Phone: +50312511349175

Job: Product Consulting Liaison

Hobby: Jogging, Motor sports, Nordic skating, Jigsaw puzzles, Bird watching, Nordic skating, Sculpting

Introduction: My name is Terence Hammes MD, I am a inexpensive, energetic, jolly, faithful, cheerful, proud, rich person who loves writing and wants to share my knowledge and understanding with you.