U
    CvfR                 '   @  s  d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZmZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, er~d d	l-m.Z. d d
l/m0Z0m1Z1 d dl2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z<m=Z= d dl>m?Z? d dl@mAZA d dlBmCZCmDZDmEZEmFZFmGZG d dlmHZH ddddddddZIddddddddZJdd dd!d"d#d$d%ZKddddddd&dddd'd(dd)d*d*d+	d,d-ZLedddddddddddddddddd.d.d/dd*d0d0d1d2d3d(dddd4d4d5d5d6d6d6d6d7d7d*d8d9d:d;ZMeddddddddddddddddd.d.d<d*d=dd1d2d3d(dddd4d4d5d5d6d6d6d6d7d7d*d>d?d@d;ZMeddddddddddddddddd.d.dAd*dd=d1d2d3d(dddd4d4d5d5d6d6d6d6d7d7d*d>d?dBd;ZMdddddddddddddddddd.d.d/dd*ddd1d2d3d(dddd4d4d5d5d6d6d6d6d7d7d*dCd9dDd;ZMedEdddddFdd*dGdHdHd0d0d*d8dI	dJdKZNedEddddLdd*dGdHdHd=dd*d>dI	dMdKZNedEddddNdd*dGdHdHdd=d*d>dI	dOdKZNdEdddddFdd*dGdHdHddd*dCdI	dPdKZNdddddddddddddQdd*d1d3d2d(d4d4d5d5d6d6d6d6d*dRdSdTdUZOdVdW ZPdXdYddZd[d0d\d]d^ZQeddddddddddddddd.d.ddd.d.dddddddddddddd_!dd*ddddd`ddd1d3d3d(d0d0d'd4d4d4d4dXd7d)d5d5d6d6d6d6dad3d3dbdcd6ddde$dfdgZRedddddddddddddd.d.ddd.d.ddddddddddddddh dd*ddddd`ddd1d3d3d(dd=d'd4d4d4d4dXd7d)d5d5d6d6d6d6dad3d3dbdcd6d>de$didgZRedddddddddddddd.d.ddd.d.ddddddddddddddj dd*ddddd`ddd1d3d3d(d=dd'd4d4d4d4dXd7d)d5d5d6d6d6d6dad3d3dbdcd6d>de$dkdgZRePddldld[dXdddmdndgZRdodp ZSeddddddddd.d.dd.dddddqdddddddddddddddrdddd1d3d3d(d0d0d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*dtdu"dvdwZTedddddddd.d.dd.dddddqdddddddddddddddxdddd1d3d2d(dd=d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"dydwZTedddddddd.d.dd.dddddqdddddddddddddddzdddd1d3d2d(d=dd'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"d{dwZTeSd|d|d}d[d*dtd~ddwZTeddddddddd.d.dd.dddddqdddddddddddddddrdddd1d3d3d(d0d0d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*ddu"ddZUedddddddd.d.dd.dddddqdddddddddddddddxdddd1d3d2d(dd=d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZUedddddddd.d.dd.dddddqdddddddddddddddzdddd1d3d2d(d=dd'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZUeSd|d|d|d[d*dd~ddZUeddddddddd.d.dd.dddddqdddddddddddddddrdddd1d3d2d(d0d0d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*ddu"ddZVedddddddd.d.dd.dddddqdddddddddddddddxdddd1d3d2d(dd=d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZVedddddddd.d.dd.dddddqdddddddddddddddzdddd1d3d2d(d=dd'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZVeSd|d|d|d[d*dd~ddZVeddddddddd.d.dd.dddddqdddddddddddddddrdddd1d3d2d(d0d0d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*ddu"ddZWedddddddd.d.dd.dddddqdddddddddddddddxdddd1d3d2d(dd=d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZWedddddddd.d.dd.dddddqdddddddddddddddzdddd1d3d2d(d=dd'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZWeSdd|d|d|d[ddd*ddddZWeddddddddd.d.dd.dddddqdddddddddddddddrdddd1d3d2d(d0d0d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*ddu"ddZXedddddddd.d.dd.dddddqdddddddddddddddxdddd1d3d2d(dd=d'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZXedddddddd.d.dd.dddddqdddddddddddddddzdddd1d3d2d(d=dd'd4d4d4d7d3d3dad3d7dcd6dsd)d(d)d5d5d6d6d6d6dbd*d>du"ddZXeSd|d|d|d[d*dd~ddZXdS )    )annotationsN)	TYPE_CHECKINGAnyCallableHashableIterableLiteralMutableMappingcastoverload)Version)	broadcast)concat)_easy_facetgrid)_LINEWIDTH_RANGE_MARKERSIZE_RANGE_add_colorbar_add_legend_assert_valid_xy_determine_guide_ensure_plottable_infer_interval_breaks_infer_xy_labels
_Normalize_process_cmap_cbar_kwargs_rescale_imshow_rgb_resolve_intervals_1dplot_resolve_intervals_2dplot_update_axesget_axisimport_matplotlib_pyplotlabel_from_attrs)Axes)PathCollectionQuadMesh)Colormap	Normalize)BarContainer)QuadContourSet)	AxesImage)Line3DPoly3DCollection)	ArrayLike)	DataArray)AspectOptionsExtendOptionsHueStyleOptionsScaleOptionsT_DataArray)	FacetGridr-   Hashable | Nonez2tuple[DataArray, DataArray, DataArray | None, str])darrayxyhuereturnc                 C  sd  t | j}|d k	r"|d k	r"td|d k	r6t| |d |d k	rJt| |d |dkrd }d }d}|d k	rt| | }| }	n,|d k	r| }| | }	n| jd }
| |
 }| }	n|d kr|d kr|d krtd|d kr|d k	rt| |d t| ||d	\}}| | }|jdkrn|| jkrZ| j|dkr*dnd}| j| }| j||d
d}	|j||d
d}ntdt| j n$| | j\}| | j\}| ||}	nt| ||d	\}}| | }	|	jdkr || jkr| j|dkrdnd}| j| }| j||d
d}|	j||d
d}	ntdt| j n$| | j\}| | j\}| ||}t	| | }| | }||	||fS )Nz2Cannot specify both x and y kwargs for line plots.r6   r7       r   z1For 2D inputs, please specify either hue, x or y.r8   )r5   r6   r7   F)transpose_coordsz3For 2D inputs, hue must be a dimension i.e. one of )
lendims
ValueErrorr   r   ndimindex	transposereprr!   )r5   r6   r7   r8   ndimsZhuenamehuepltZhuelabelxpltypltdimZxnameZ
otherindexZotherdimZxdimZhuedimZynameZydim rI   >/tmp/pip-unpacked-wheel-h316xyqg/xarray/plot/dataarray_plot.py_infer_line_dataB   sx    





rK   r6   r8   sizezMutableMapping[str, Hashable]zIterable[str])r5   	dims_plotdefault_guessr9   c                   sx   dd |  D  t fdd| jD }t||D ] \}}||ddkr4|||< q4|  D ]\}}t| || q^|S )a  
    Guess what dims to plot if some of the values in dims_plot are None which
    happens when the user has not defined all available ways of visualizing
    the data.

    Parameters
    ----------
    darray : DataArray
        The DataArray to check.
    dims_plot : T_DimsPlot
        Dims defined by the user to plot.
    default_guess : Iterable[str], optional
        Default values and order to retrieve dims if values in dims_plot is
        missing, default: ("x", "hue", "size").
    c                 S  s   i | ]\}}|d k	r||qS NrI   .0kvrI   rI   rJ   
<dictcomp>   s       z$_infer_plot_dims.<locals>.<dictcomp>c                 3  s   | ]}|   kr|V  qd S rP   )valuesrR   rT   Zdims_plot_existrI   rJ   	<genexpr>   s      z#_infer_plot_dims.<locals>.<genexpr>N)itemstupler>   zipgetr   )r5   rN   rO   Z
dims_availrS   rT   rI   rX   rJ   _infer_plot_dims   s    
r^   r2   z
None | strzdict[str, T_DataArray])r5   rN   plotfunc_namer9   c                   s   t  |} jdkrg }t jtjrdD ]T}||d }|d k	r,| jkr,tj 	|di }t
 |g|d |||  q, jd
|   j jd t d}| fdd	| D  tt| t|  }|S )Nr:   )zr6   )rH   .)Z_stacked_dim)r7   c                   s"   i | ]\}}|d k	r| | qS rP   rI   rQ   r5   rI   rJ   rU      s       z%_infer_line_data2.<locals>.<dictcomp>).)r^   r@   np
issubdtypedtypeZfloatingr]   r>   nanZiselr   appendrB   stackdictupdaterZ   r\   keysr   rV   )r5   rN   r_   Zdims_TrT   rH   Z
darray_nanoutrI   rb   rJ   _infer_line_data2   s     


rm   )rowcolcol_wrapaxr8   subplot_kws
int | NoneAxes | Nonedict[str, Any] | Noner   )	r5   rn   ro   rp   rq   r8   rr   kwargsr9   c                K  s   |    } t| j}|| || || t|}	|	dksN| jdkrVtd|	dkr|sf|r||d< ||d< ||d< ||d< |	dkrt}
||d	< q|	d
kr|rt}
||d	< qt	}
||d< n|s|s|rt
dt}
||d< |
| f|S )a  
    Default plot of DataArray using :py:mod:`matplotlib:matplotlib.pyplot`.

    Calls xarray plotting function based on the dimensions of
    the squeezed DataArray.

    =============== ===========================
    Dimensions      Plotting function
    =============== ===========================
    1               :py:func:`xarray.plot.line`
    2               :py:func:`xarray.plot.pcolormesh`
    Anything else   :py:func:`xarray.plot.hist`
    =============== ===========================

    Parameters
    ----------
    darray : DataArray
    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 or None, optional
        Use together with ``col`` to wrap faceted plots.
    ax : matplotlib axes object, optional
        Axes on which to plot. By default, use the current axes.
        Mutually exclusive with ``size``, ``figsize`` and facets.
    hue : Hashable or None, optional
        If passed, make faceted line plots with hue on this dimension name.
    subplot_kws : dict, optional
        Dictionary of keyword arguments for Matplotlib subplots
        (see :py:meth:`matplotlib:matplotlib.figure.Figure.add_subplot`).
    **kwargs : optional
        Additional keyword arguments for Matplotlib.

    See Also
    --------
    xarray.DataArray.squeeze
    r   No numeric data to plot.)r:      rr   rn   ro   rp   r:   r8   rx   zdOnly 1d and 2d plots are supported for facets in xarray. See the package `Seaborn` for more options.rq   )ZsqueezeZcomputesetr>   discardr=   rM   	TypeErrorline
pcolormeshr?   hist)r5   rn   ro   rp   rq   r8   rr   rv   Z	plot_dimsrD   plotfuncrI   rI   rJ   plot   s<    1






r   T)rn   ro   figsizeaspectrM   rq   r8   r6   r7   	xincrease	yincreasexscaleyscalexticksyticksxlimylim
add_legend_labelsNoneIterable[float] | Noner.   float | Nonebool | Noner1   ArrayLike | Noneboolzlist[Line3D])r5   argsrn   ro   r   r   rM   rq   r8   r6   r7   r   r   r   r   r   r   r   r   r   r   rv   r9   c                O  s   d S rP   rI   r5   rn   ro   r   r   rM   rq   r8   r6   r7   r   r   r   r   r   r   r   r   r   r   r   rv   rI   rI   rJ   r|   ;  s    r|   )ro   r   r   rM   rq   r8   r6   r7   r   r   r   r   r   r   r   r   r   r   r   zFacetGrid[DataArray])r   rn   ro   r   r   rM   rq   r8   r6   r7   r   r   r   r   r   r   r   r   r   r   rv   r9   c                O  s   d S rP   rI   r   rI   rI   rJ   r|   W  s    )rn   r   r   rM   rq   r8   r6   r7   r   r   r   r   r   r   r   r   r   r   c                O  s   d S rP   rI   r   rI   rI   rJ   r|   s  s    z#list[Line3D] | FacetGrid[DataArray]c          $   
   O  s  |s|rBt   }||d |d t| tfddi|S t| j}|dks^| jdkrft	d|dkr~t
dj|d	|d
kr|dd
}nd|kstt||||}t| ||	|\}}}}t| | |\}}}}}t||d} t||d}!t|| |j||f||}"|rT| dk	r2||  |!dk	rF||! ||   | jdkr|r|dk	stt|j|"t| |d t|jtjr| D ]}#|# d |#!d qt"||
|||||||	 |"S )a
  
    Line plot of DataArray values.

    Wraps :py:func:`matplotlib:matplotlib.pyplot.plot`.

    Parameters
    ----------
    darray : DataArray
        Either 1D or 2D. If 2D, one of ``hue``, ``x`` or ``y`` must be provided.
    row : Hashable, optional
        If passed, make row faceted plots on this dimension name.
    col : Hashable, optional
        If passed, make column faceted plots on this dimension name.
    figsize : tuple, optional
        A tuple (width, height) of the figure in inches.
        Mutually exclusive with ``size`` and ``ax``.
    aspect : "auto", "equal", scalar or None, optional
        Aspect ratio of plot, so that ``aspect * size`` gives the *width* in
        inches. Only used if a ``size`` is provided.
    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``.
    ax : matplotlib axes object, optional
        Axes on which to plot. By default, the current is used.
        Mutually exclusive with ``size`` and ``figsize``.
    hue : Hashable, optional
        Dimension or coordinate for which you want multiple lines plotted.
        If plotting against a 2D coordinate, ``hue`` must be a dimension.
    x, y : Hashable, optional
        Dimension, coordinate or multi-index level for *x*, *y* axis.
        Only one of these may be specified.
        The other will be used for values from the DataArray on which this
        plot method is called.
    xincrease : bool or None, optional
        Should the values on the *x* axis be increasing from left to right?
        if ``None``, use the default for the Matplotlib function.
    yincrease : bool or None, optional
        Should the values on the *y* axis be increasing from top to bottom?
        if ``None``, use the default for the Matplotlib function.
    xscale, yscale : {'linear', 'symlog', 'log', 'logit'}, optional
        Specifies scaling for the *x*- and *y*-axis, respectively.
    xticks, yticks : array-like, optional
        Specify tick locations for *x*- and *y*-axis.
    xlim, ylim : array-like, optional
        Specify *x*- and *y*-axis limits.
    add_legend : bool, default: True
        Add legend with *y* axis coordinates (2D inputs only).
    *args, **kwargs : optional
        Additional arguments to :py:func:`matplotlib:matplotlib.pyplot.plot`.

    Returns
    -------
    primitive : list of Line3D or FacetGrid
        When either col or row is given, returns a FacetGrid, otherwise
        a list of matplotlib Line3D objects.
    rv   r5   kindr|   r   rw   rx   zZLine plots are for 1- or 2-dimensional DataArrays. Passed DataArray has {ndims} dimensions)rD   rI   r   extraNZhandleslabelstitle   right)#localscopyrj   popr   r|   r=   r>   rM   r{   r?   formatAssertionErrorr   rK   r   to_numpyr!   r   r   
set_xlabel
set_ylabel	set_title_title_for_slicer@   legendlistrc   rd   re   
datetime64get_xticklabelsset_rotationset_har   )$r5   rn   ro   r   r   rM   rq   r8   r6   r7   r   r   r   r   r   r   r   r   r   r   r   rv   allargsrD   rF   rG   rE   Z	hue_labelZxplt_valZyplt_valZx_suffixZy_suffixZxlabelZylabel	primitivexlabelsrI   rI   rJ   r|     sV    Q


  





pre)where	drawstyledsrn   ro   zLiteral[('pre', 'post', 'mid')]z
str | None)	r5   r   r   r   r   rn   ro   rv   r9   c                O  s   d S rP   rI   r5   r   r   r   rn   ro   r   rv   rI   rI   rJ   step"  s    r   )r   r   r   ro   c                O  s   d S rP   rI   r   rI   rI   rJ   r   0  s    )r   r   r   rn   c                O  s   d S rP   rI   r   rI   rI   rJ   r   >  s    c                O  sb   |dkrt d|dk	r.|dkr&|}ntd|dkr:d}d| | }t| f||||d|S )a  
    Step plot of DataArray values.

    Similar to :py:func:`matplotlib:matplotlib.pyplot.step`.

    Parameters
    ----------
    where : {'pre', 'post', 'mid'}, default: 'pre'
        Define where the steps should be placed:

        - ``'pre'``: The y value is continued constantly to the left from
          every *x* position, i.e. the interval ``(x[i-1], x[i]]`` has the
          value ``y[i]``.
        - ``'post'``: The y value is continued constantly to the right from
          every *x* position, i.e. the interval ``[x[i], x[i+1])`` has the
          value ``y[i]``.
        - ``'mid'``: Steps occur half-way between the *x* positions.

        Note that this parameter is ignored if one coordinate consists of
        :py:class:`pandas.Interval` values, e.g. as a result of
        :py:func:`xarray.Dataset.groupby_bins`. In this case, the actual
        boundaries of the interval are used.
    drawstyle, ds : str or None, optional
        Additional drawstyle. Only use one of drawstyle and ds.
    row : Hashable, optional
        If passed, make row faceted plots on this dimension name.
    col : Hashable, optional
        If passed, make column faceted plots on this dimension name.
    *args, **kwargs : optional
        Additional arguments for :py:func:`xarray.plot.line`.

    Returns
    -------
    primitive : list of Line3D or FacetGrid
        When either col or row is given, returns a FacetGrid, otherwise
        a list of matplotlib Line3D objects.
    >   r   midpostz7'where' argument to step must be 'pre', 'post' or 'mid'Nz'ds and drawstyle are mutually exclusiver;   zsteps-)r   ro   rn   )r?   r{   r|   r   rI   rI   rJ   r   L  s    /)r   rM   r   rq   r   r   r   r   r   r   r   r   z+tuple[np.ndarray, np.ndarray, BarContainer])r5   r   r   rM   r   rq   r   r   r   r   r   r   r   r   rv   r9   c             
   O  s   t |dkst| jdks$| jdkr,tdt||||}t|  }|t	
| }|j|f|}||   |t|  t||||||	|
||	 |S )a  
    Histogram of DataArray.

    Wraps :py:func:`matplotlib:matplotlib.pyplot.hist`.

    Plots *N*-dimensional arrays by first flattening the array.

    Parameters
    ----------
    darray : DataArray
        Can have any number of dimensions.
    figsize : Iterable of float, optional
        A tuple (width, height) of the figure in inches.
        Mutually exclusive with ``size`` and ``ax``.
    aspect : "auto", "equal", scalar or None, optional
        Aspect ratio of plot, so that ``aspect * size`` gives the *width* in
        inches. Only used if a ``size`` is provided.
    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``.
    ax : matplotlib axes object, optional
        Axes on which to plot. By default, use the current axes.
        Mutually exclusive with ``size`` and ``figsize``.
    xincrease : bool or None, optional
        Should the values on the *x* axis be increasing from left to right?
        if ``None``, use the default for the Matplotlib function.
    yincrease : bool or None, optional
        Should the values on the *y* axis be increasing from top to bottom?
        if ``None``, use the default for the Matplotlib function.
    xscale, yscale : {'linear', 'symlog', 'log', 'logit'}, optional
        Specifies scaling for the *x*- and *y*-axis, respectively.
    xticks, yticks : array-like, optional
        Specify tick locations for *x*- and *y*-axis.
    xlim, ylim : array-like, optional
        Specify *x*- and *y*-axis limits.
    **kwargs : optional
        Additional keyword arguments to :py:func:`matplotlib:matplotlib.pyplot.hist`.

    r   rw   )r=   r   r@   rM   r{   r   rc   ravelr   pdZnotnullr~   r   r   r   r!   r   )r5   r   rM   r   rq   r   r   r   r   r   r   r   r   r   rv   Zno_nanr   rI   rI   rJ   r~     s    8r~   c              '     s   d} j  d|  _ tj dddddddddddddddddddddddddddddddddddd!dd	d
d
d
d
dd
d
d
d
ddddddddddddddddddddddddd	d$ fdd}|`|S )z'Decorator for common 1d plotting logic.aW  
    Parameters
    ----------
    darray : DataArray
        Must be 2 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].
    z : Hashable or None, optional
        If specified plot 3D and use this coordinate for *z* axis.
    hue : Hashable or None, optional
        Dimension or coordinate for which you want multiple lines plotted.
    hue_style: {'discrete', 'continuous'} or None, optional
        How to use the ``hue`` variable:

        - ``'continuous'`` -- continuous color scale
          (default for numeric ``hue`` variables)
        - ``'discrete'`` -- a color for each unique value,
          using the default color cycle
          (default for non-numeric ``hue`` variables)

    markersize: Hashable or None, optional
        scatter only. Variable by which to vary size of scattered points.
    linewidth: Hashable or None, optional
        Variable by which to vary linewidth.
    row : Hashable, optional
        If passed, make row faceted plots on this dimension name.
    col : Hashable, optional
        If passed, make column faceted plots on this dimension name.
    col_wrap : int, optional
        Use together with ``col`` to wrap faceted plots
    ax : matplotlib axes object, optional
        If None, uses the current axis. Not applicable when using facets.
    figsize : Iterable[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 in
        inches. Only used if a ``size`` is provided.
    xincrease : bool or None, default: True
        Should the values on the x axes be increasing from left to right?
        if None, use the default for the matplotlib function.
    yincrease : bool or None, default: True
        Should the values on the y axes be increasing from top to bottom?
        if None, use the default for the matplotlib function.
    add_legend : bool or None, optional
        If True use xarray metadata to add a legend.
    add_colorbar : bool or None, optional
        If True add a colorbar.
    add_labels : bool or None, optional
        If True use xarray metadata to label axes
    add_title : bool or None, optional
        If True use xarray metadata to add a title
    subplot_kws : dict, optional
        Dictionary of keyword arguments for matplotlib subplots. Only applies
        to FacetGrid plotting.
    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 : ArrayLike or None, optional
        Specify x-axes limits.
    ylim : ArrayLike or None, optional
        Specify y-axes limits.
    cmap : matplotlib colormap name or colormap, optional
        The mapping from data values to color space. Either a
        Matplotlib colormap name or object. If not provided, this will
        be either ``'viridis'`` (if the function infers a sequential
        dataset) or ``'RdBu_r'`` (if the function infers a diverging
        dataset).
        See :doc:`Choosing Colormaps in Matplotlib <matplotlib:tutorials/colors/colormaps>`
        for more information.

        If *seaborn* is installed, ``cmap`` may also be a
        `seaborn color palette <https://seaborn.pydata.org/tutorial/color_palettes.html>`_.
        Note: if ``cmap`` is a seaborn color palette,
        ``levels`` must also be specified.
    vmin : float or None, optional
        Lower value to anchor the colormap, otherwise it is inferred from the
        data and other keyword arguments. When a diverging dataset is inferred,
        setting `vmin` or `vmax` 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.
    vmax : float or None, optional
        Upper value to anchor the colormap, otherwise it is inferred from the
        data and other keyword arguments. When a diverging dataset is inferred,
        setting `vmin` or `vmax` 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.
    norm : matplotlib.colors.Normalize, optional
        If ``norm`` has ``vmin`` or ``vmax`` specified, the corresponding
        kwarg must be ``None``.
    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.
    levels : int or array-like, 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)``.
    **kwargs : optional
        Additional arguments to wrapped matplotlib function

    Returns
    -------
    artist :
        The same type of primitive artist that the wrapped matplotlib
        function returns
    

__module____name____qualname____doc__assignedNT)!r6   r7   r`   r8   	hue_style
markersize	linewidthrn   ro   rp   rq   r   rM   r   r   r   r   add_colorbar
add_labels	add_titlerr   r   r   r   r   r   r   cmapvminvmaxnormextendlevelsr-   r   r4   r0   rs   rt   r   r   r   bool | Iterable[bool]r   ru   r1   r   str | Colormap | NoneNormalize | Noner/   )$r5   r   r6   r7   r`   r8   r   r   r   rn   ro   rp   rq   r   rM   r   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   r9   c       !   :   
     s  |d krt  }|s|	rr|d k	r*|jdd t  }$|$|$d |$d t j |$d< t| fddi|$S | jdks| j	dkrt
d	|"d
kr|#dd
}"|"r\d|#kstd}%|d kst|"d }t|"dkr|d kst|"d }t|"dkr|d kst|"d }t|"dkr4|d ks,t|"d }t|"dkrLt|%ntj|%tdd ~"|#dd}&jdkr|}'t}(n|}'t}(t ||||'d})t| |)j}*|*dd }+|*dd },|*dd }-|#j|-d |*dd }.|*dd }/t|.d}0|#j|0jd t|/|(|&d}1|#j|1jd |#d i }2|#d!i }3|0jd k	r|0jsn|3j|0j|0jd" |#d#|0j}!ttd$|0jjft \ }3|2s fd%d&d'D }4|2jf |4 |d k	r |d kr|jdd t||||f|}t }5t |5j!j"t d(k r|j#d)d)d* n|j#d)d)dd+ nt||||f|}|+|,f||d,|2|#}6t$%t$&|rr|rr|'| (  t)|0|1||jd-\}7}8|7rd.|3krt*|0j|3d.< t+|6||#d/d |3  |8rdjd0krt,|s|7s|0ntd |1|6|jd1 nh|0jd k	rt-td$|0j. }9n|0jg}9jd2krN|j/|6d3 |9t*|0jd4 n|j/|6|9t*|0jd4 t0|||||||||	 |6S )5N3d)
projectionrv   r5   r   r   Zplot1dr   rw   rI   r   YUsing positional arguments is deprecated for plot methods, use keyword arguments instead.r:   rx         
stacklevel_is_facetgridFscatter)r6   r`   r8   rM   r6   r7   r`   )zpltr8   rM   )data)rE   )r   widthr   )sizepltcmap_params_subsetcbar_kwargs)r   ticksr   r-   c                   s   i | ]}| | qS rI   rI   )rR   vvcmap_paramsrI   rJ   rU     s      z0_plot1d.<locals>.newplotfunc.<locals>.<dictcomp>)r   r   r   r   3.5.0r   )azimelev)r   r   Zvertical_axis)rq   r   )r_   labelcbar_ax)r   r|   )Z	legend_axr   r~   ra   r   )1ri   rj   r   r   r   globalsr   r   r@   rM   r{   r   r=   r?   warningswarnDeprecationWarningr   r   rm   r   rV   r   Zdata_is_numericr   r   r]   r   r   r
   r   r    r   
matplotlib__version__Z	view_initrc   anyasarrayr   r   r   r!   r   r   r   r   r   r   ):r5   r6   r7   r`   r8   r   r   r   rn   ro   rp   rq   r   rM   r   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   rv   r   msgr   Zsize_Zsize_rrN   pltsrF   rG   r   rE   r   Zhueplt_normZsizeplt_normr   r   Zckwpltr   Zadd_colorbar_Zadd_legend_Zhueplt_norm_valuesr   r   rJ   newplotfuncU  s(   ,



  

	

  
          z_plot1d.<locals>.newplotfuncr   	functoolswraps__wrapped__r   Z	commondocr   rI   r   rJ   _plot1d  sV    z ^ Yr   r   zIterable[DataArray]zIterable[bool]r"   )r   darrayssuffixesrotate_labelsrq   r9   c                 C  s   t | tr| gd n| } td| |||D ]\}}}}}	|d kr@q(|rnt||d}
|
d k	rnt|d| d|
 |	r(t|jtjr(t|d| d D ]}|	d |
d	 qq(d S )
Nr   r6   r7   r`   r   set_r   get_
ticklabelsr   r   )
isinstancer   r\   r!   getattrrc   rd   re   r   r   r   )r   r   r   r   rq   axisZ	add_labelr5   suffixZrotate_labelr   r   rI   rI   rJ   _add_labels5  s$        
r  )!r6   r7   r`   r8   r   r   r   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   r0   r   r   r/   r#   )$r5   r   r6   r7   r`   r8   r   r   r   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   r9   c       !   $      O  s   d S rP   rI   $r5   r6   r7   r`   r8   r   r   r   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   rv   rI   rI   rJ   r   S  s    'r   ) r6   r7   r`   r8   r   r   r   r   rM   r   rq   rn   rp   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   c       !   $      O  s   d S rP   rI   r  rI   rI   rJ   r   }  s    ') r6   r7   r`   r8   r   r   r   r   rM   r   rq   ro   rp   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   c       !   $      O  s   d S rP   rI   r  rI   rI   rJ   r     s    'zDataArray | None)rF   rG   rq   r   r9   c                   s  t  }d|ksd|krtd|dd}|dd}|dd}|j|dd	d
 |dk	rr|j|  d |dk	r|j|  d t|jjtdk rdddg}	n
dddg}	t	| ||d  fdd|	D }
dd |
D }|j
dd |D |}t||dd| |S )zfScatter variables against each other.

    Wraps :py:func:`matplotlib:matplotlib.pyplot.scatter`.
    urT   z&u, v are not allowed in scatter plots.r   NrE   r   
edgecolorsw)r
  )c)sr   r6   r`   r7   r   c                   s   g | ]} | qS rI   rI   rW   Z	plts_dictrI   rJ   
<listcomp>  s     zscatter.<locals>.<listcomp>c                 S  s   g | ]}|d k	r|qS rP   rI   rR   prI   rI   rJ   r    s      c                 S  s   g | ]}|   qS rI   )r   r   r  rI   rI   rJ   r    s     )r;   r;   r;   )TFF)r    r?   r   rj   r   r   r   r   r   ri   r   r  )rF   rG   rq   r   rv   r   r   rE   r   Z
axis_orderZplts_or_noner   r   rI   r  rJ   r     s(    
c              &     s   d} j  d|  _ tj ddddddddddddddddddddddddddddddddddd d	d
dddddddddddddddddddddddddddddddd
d
d# fdd}|`|S )z'Decorator for common 2d plotting logic.a  
    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* in
        inches. 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 the
        data and other keyword arguments. When a diverging dataset is inferred,
        setting `vmin` or `vmax` 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.
    vmax : float or None, optional
        Upper value to anchor the colormap, otherwise it is inferred from the
        data and other keyword arguments. When a diverging dataset is inferred,
        setting `vmin` or `vmax` 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.
    cmap : matplotlib colormap name or colormap, 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).
        See :doc:`Choosing Colormaps in Matplotlib <matplotlib:tutorials/colors/colormaps>`
        for more information.

        If *seaborn* is installed, ``cmap`` may also be a
        `seaborn color palette <https://seaborn.pydata.org/tutorial/color_palettes.html>`_.
        Note: if ``cmap`` is a seaborn color palette and the plot type
        is not ``'contour'`` or ``'contourf'``, ``levels`` must also be specified.
    center : float, 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.
    robust : bool, 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.
    levels : int or array-like, 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_intervals : bool, 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.
    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 used
        for 2D and faceted plots.
        (see :py:meth:`matplotlib: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 :meth:`matplotlib: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 : ArrayLike or None, optional
        Specify x-axes limits.
    ylim : ArrayLike or None, optional
        Specify y-axes limits.
    norm : matplotlib.colors.Normalize, optional
        If ``norm`` has ``vmin`` or ``vmax`` specified, the corresponding
        kwarg must be ``None``.
    **kwargs : optional
        Additional keyword arguments to wrapped Matplotlib function.

    Returns
    -------
    artist :
        The same type of primitive artist that the wrapped Matplotlib
        function returns.
    r   r   r   NTF) r6   r7   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   r   centerrobustr   r   infer_intervalscolorsrr   r   r   r   r   r   r   r   r   r   r-   r   r4   r   r   rt   rs   r   r   r   r/   r   str | ArrayLike | Noneru   r1   r   )#r5   r   r6   r7   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   r   r  r  r   r   r  rr   r   r   r   r   r   r   r   r   r   rv   r9   c           <   
     s6  |!rbd}#|d kst |!d }t|!dkr<|d ks4t |!d }t|!dkrRt|#ntj|#tdd ~!|d krd}jdksjdkr|d krd	}jd
ko| jd|d k	 |d k	 k}$|$rd	}|s|d k	s|d k	rt| 	 |||} d\}}}|d krt
 }jdkr<|"dd	s<|d kr4ddlm}% ~%d|d< d	}&d	}'|sH|rt  }(|(d= |(d= |(|(d t j |(d< t| fddi|(S | jdks| jdkrtdt })jdkr|"dd	s|d k	rdd l}*t||*jjstd|"dd }+|+d k	r(jd
kr(tdn|+d k	r@|$s@tdt| |||$|+d\},}-| |, }.| |- }/|.jdks|/jdksjdkr|.| }.|/| }/| j}0n|/jd |.jd f}0|$r|-|,f  t fdd| jD  }0|0| jkr | j|0ddi} |. }1|/ }2| j d	d }3t!|1j\}4}5t!|2j\}6}7t"|4|6|3 t#|3j$ft d|"dd	i\}8}djkr|8d! |"d!< |8d" |"d"< t|t%rd |8d#< ||"d$< d%jkr||"d&< ||"d'< ||"d(< d
jkrt|t%rtd)t&||||f|}|4|6|3f||8d# |8d* |8d+ |8d, d-|"}9|r|'t(| |, |5 |)t(| |- |7 |*| +  jdkr|,t(|  |r|rd.|krt(| |d.< t-|9||||8}:n|d k	s|rtd/d0|"krd }t.||
|||||||	 t/0|4j1t/j2r2|3 D ]};|;4d1 |;5d2 q|9S )3Nr   r   r:   rx   r   TcontoursurfaceFimshowr   )NNFr   )Axes3Dr   r   r5   
imshow_rgbrv   r   r   Z	dataarrayrw   zEIf ax is passed to surface(), it must be created with projection="3d"rgbz,The "rgb" keyword is only valid for imshow()zVThe "rgb" keyword is only valid for imshow()with a three-dimensional array (per facet))r5   r6   r7   r  r  c                 3  s   | ]}| kr|V  qd S rP   rI   )rR   dZyx_dimsrI   rJ   rY     s      z/_plot2d.<locals>.newplotfunc.<locals>.<genexpr>r<   )r   r   r   r   r  r}   r  r   r   z6plt.imshow's `aspect` kwarg is not available in xarrayr   r   r   )rq   r   r   r   r   r   z>cbar_ax and cbar_kwargs can't be used with add_colorbar=False.originr   r   )6r   r=   r?   r   r   r   r   r@   r   Zas_numpyri   r]   Zmpl_toolkits.mplot3dr  r   r   rj   r   r   r   rM   r{   r    mpl_toolkitsr  Zmplot3dr   Zbroadcast_liker>   r[   rB   r   Zto_masked_arrayr   r   r   r   strr   r   r!   r   r   r   Z
set_zlabelr   r   rc   rd   re   r   r   r   r   )<r5   r6   r7   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   r   r  r  r   r   r  r  rr   r   r   r   r   r   r   r   r   r   r   rv   r   r  r  ZsharexZshareyr   r   r   r  ZxlabZylabZxvalZyvalr>   ZxvalnpZyvalnpZzvalrF   Z
xlab_extrarG   Z
ylab_extrar   r   Zcbarr   r   r  rJ   r     s6   *






    
$


	
        
z_plot2d.<locals>.newplotfuncr   r   rI   r   rJ   _plot2d  sT    z \ ~r"  F)r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   r   r  r  r   r   r  r  rr   r   r   r   r   r   r   r   r   r   r  r)   )"r5   r6   r7   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   r   r  r  r   r   r  rr   r   r   r   r   r   r   r   r   r   rv   r9   c          "      K  s   d S rP   rI   "r5   r6   r7   r   rM   r   rq   rn   ro   rp   r   r   r   r   r   r   r   r  r  r   r   r  r  rr   r   r   r   r   r   r   r   r   r   rv   rI   rI   rJ   r    s    &r  )r   rM   r   rq   rn   rp   r   r   r   r   r   r   r   r  r  r   r   r  r  rr   r   r   r   r   r   r   r   r   r   c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r    s    &)r   rM   r   rq   ro   rp   r   r   r   r   r   r   r   r  r  r   r   r  r  rr   r   r   r   r   r   r   r   r   r   c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r    s    &z
np.ndarrayznp.ma.core.MaskedArray)r6   r7   r`   rq   rv   r9   c                 K  s  | j dks|j dkrtddd }|| \}}||\}}	ddd}
t|dsXd	|
d
< |
| |
d dkr|||	|g|
d< n||||	g|
d< |j dkr|jd dkrtjj|jdd d |jd}t	|jtj
r|d9 }tjj||fdd}n| }d|tj|jdddf< |j|f|
}d| fd|ffD ]P\}}t	|jtr6t|d| dtt| t|d| d| q6|S )az  
    Image plot of 2D DataArray.

    Wraps :py:func:`matplotlib: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 :py:func:`matplotlib:matplotlib.pyplot.imshow`, which ignores ``vmin``/``vmax``
    for RGB(A) data,
    xarray *will* use ``vmin`` and ``vmax`` for RGB(A) data
    by applying a single scaling factor and offset to all bands.
    Passing  ``robust=True`` infers ``vmin`` and ``vmax``
    :ref:`in the usual way <robust-plotting>`.
    Additionally the y-axis is not inverted by default, you can
    restore the matplotlib behavior by setting `yincrease=False`.

    .. note::
        This function needs uniformly spaced coordinates to
        properly label the axes. Call :py:meth:`DataArray.plot` to check.

    The pixels are centered on the coordinates. For example, if the coordinate
    value is 3.2, then the pixels for those coordinates will be centered on 3.2.
    r:   zBimshow requires 1D coordinates, try using pcolormesh or contour(f)c                 S  sh   t | jtrdt| d fS zd| d | d   }W n tk
rN   d}Y nX | d | | d | fS )z%Center the pixels on the coordinates.g      g      ?r:   r   g?ra   )rc   rd   re   r!  r=   
IndexError)r6   ZxsteprI   rI   rJ   _center_pixels%  s    
zimshow.<locals>._center_pixelsupperZnearest)r  interpolationr   autor   r  Zextentr   ra   Nrx   )r:   )re      )r  r   r6   r7   r   r   r  )r@   r?   hasattrrj   shaperc   maZonesre   rd   integerZconcatenater   r   maskr  r!  r  Zaranger=   )r6   r7   r`   rq   rv   r%  leftr   topZbottomdefaultsalphar   r  rT   rI   rI   rJ   r    s8    


  r(   c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r  a  s    &r  c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r    s    &c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r    s    &c                 K  s   |j | ||f|}|S )zc
    Contour plot of 2D DataArray.

    Wraps :py:func:`matplotlib:matplotlib.pyplot.contour`.
    )r  r6   r7   r`   rq   rv   r   rI   rI   rJ   r    s    	c          "      K  s   d S rP   rI   r#  rI   rI   rJ   contourf  s    &r4  c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r4    s    &c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r4  ;  s    &c                 K  s   |j | ||f|}|S )zk
    Filled contour plot of 2D DataArray.

    Wraps :py:func:`matplotlib:matplotlib.pyplot.contourf`.
    )r4  r3  rI   rI   rJ   r4  d  s    	r$   c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r}   q  s    &r}   c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r}     s    &c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r}     s    &zScaleOptions | None)r6   r7   r`   rq   r   r   rv   r9   c           	      K  s  t | } |dkr:t|dr6t| jdkr0d}q:d}nd}|rt | jtst | d t |d ks| jdkrt | d t |d krt| jdkrt	| d|d} nt	| d|d} t	| d|d} |r8t |jts8t |d t |d kr8t|jdkrt	|d|d}nt	|d|d}t	|d|d}|
d |j| ||f|}t|ds| jdkr|jdkr|| d | d	  ||d |d	  |S )
zj
    Pseudocolor plot of 2D DataArray.

    Wraps :py:func:`matplotlib:matplotlib.pyplot.pcolormesh`.
    Nr   r:   TFr   )Zcheck_monotonicscale)r  r5  ra   )rc   r   r*  r=   r+  rd   re   r!  r@   r   Zgridr}   Zset_xlimZset_ylim)	r6   r7   r`   rq   r   r   r  rv   r   rI   rI   rJ   r}     sJ    


$r+   c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r  0	  s    &r  c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r  Y	  s    &c          "      K  s   d S rP   rI   r#  rI   rI   rJ   r  	  s    &c                 K  s   |j | ||f|}|S )zy
    Surface plot of 2D DataArray.

    Wraps :py:meth:`matplotlib:mpl_toolkits.mplot3d.axes3d.Axes3D.plot_surface`.
    )Zplot_surfacer3  rI   rI   rJ   r  	  s    	)rL   )N)T)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NNN)NN)NN)NN)Y
__future__r   r   r   typingr   r   r   r   r   r   r	   r
   r   Znumpyrc   Zpandasr   Zpackaging.versionr   Zxarray.core.alignmentr   Zxarray.core.concatr   Zxarray.plot.facetgridr   Zxarray.plot.utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   Zmatplotlib.axesr"   Zmatplotlib.collectionsr#   r$   Zmatplotlib.colorsr%   r&   Zmatplotlib.containerr'   Zmatplotlib.contourr(   Zmatplotlib.imager)   Zmpl_toolkits.mplot3d.art3dr*   r+   Znumpy.typingr,   Zxarray.core.dataarrayr-   Zxarray.core.typesr.   r/   r0   r1   r2   r3   rK   r^   rm   r   r|   r   r~   r   r  r   r"  r  r  r4  r}   r  rI   rI   rI   rJ   <module>   s8  ,PX % *"[@>> > $$$"A0M  `Z)Z)Z) 1     V(  V(  V(_  V(  V(  V(  V(  V(  V(  V(  V(  V(    C  V(  V(  V(