HOME


sh-3ll 1.0
DIR:/opt/cloudlinux/venv/lib64/python3.11/site-packages/xarray/plot/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/xarray/plot/__pycache__/plot.cpython-311.pyc
�

���h�F��
�dZddlmZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
d�Zd�Z		dd
�Z		dd�Zd
�Zdd�Zd�ZGd�de��Zd�Zed���Zed���Zed���Zd�Zed���ZdS)zw
Use this module directly:
    import xarray.plot as xplt

Or use the methods on a DataArray:
    DataArray.plot._____
�)�divisionN�)�_determine_cmap_params�_infer_xy_labels)�	FacetGridc�:��t�fd�|D����S)z>
    Is the numpy array a sub dtype of anything in types?
    c3�L�K�|]}tj�j|��V��dS�N)�np�
issubdtype�dtype)�.0�t�arrs  ��E/opt/cloudlinux/venv/lib/python3.11/site-packages/xarray/plot/plot.py�	<genexpr>z_right_dtype.<locals>.<genexpr>s1�����:�:�q�r�}�S�Y��*�*�:�:�:�:�:�:�)�any)r�typess` r�_right_dtypers(����:�:�:�:�E�:�:�:�:�:�:rc���tjtjtjtjg�t�fd�|D����st
d���dS)z\
    Raise exception if there is anything in args that can't be plotted on
    an axis.
    c3�\�K�|]&}ttj|�����V��'dSr
)rr�array)r�x�	plottypess  �rrz$_ensure_plottable.<locals>.<genexpr>$s5�����B�B��|�B�H�Q�K�K��3�3�B�B�B�B�B�Brz5Plotting requires coordinates to be numeric or dates.N)r�floating�integer�timedelta64�
datetime64r�	TypeError)�argsrs @r�_ensure_plottabler"sc���
��b�j�"�.�"�-�H�I��B�B�B�B�T�B�B�B�B�B�%��$�%�%�	%�%�%r�c
	��|
�dd��}|�td���t|||||||	���}|j|||fi|
��S)z�
    Convenience method to call xarray.plot.FacetGrid from 2d plotting methods

    kwargs are the arguments to 2d plotting method
    �axNz)Can't use axes when making faceted plots.)�data�col�row�col_wrap�aspect�size�subplot_kws)�pop�
ValueErrorr�
map_dataarray)
�darray�plotfuncr�yr(r'r)r*r+r,�kwargsr%�gs
             r�_easy_facetgridr5)so��
���D�$�	�	�B�	�~��D�E�E�E��v�3�C�(��d��	E�	E�	E�A��1�?�8�Q��4�4�V�4�4�4r�{�G�z�?c��|���}t|j��}|�|��|�|��t	|��}	d}
|	dkr|s|rt|
���t}n<|	dkr||d<||d<||d<||d<t}n|s|rt|
���t}||d<||fi|��S)	a
    Default plot of DataArray using matplotlib.pyplot.

    Calls xarray plotting function based on the dimensions of
    darray.squeeze()

    =============== ===========================
    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 : string, optional
        If passed, make row faceted plots on this dimension name
    col : string, optional
        If passed, make column faceted plots on this dimension name
    col_wrap : integer, optional
        Use together with ``col`` to wrap faceted plots
    ax : matplotlib axes, optional
        If None, uses the current axis. Not applicable when using facets.
    rtol : number, optional
        Relative tolerance used to determine if the indexes
        are uniformly spaced. Usually a small positive number.
    subplot_kws : dict, optional
        Dictionary of keyword arguments for matplotlib subplots. Only applies
        to FacetGrid plotting.
    **kwargs : optional
        Additional keyword arguments to matplotlib

    z]Only 2d plots are supported for facets in xarray. See the package `Seaborn` for more options.r�r(r'r)r,r%)	�squeeze�set�dims�discard�lenr.�line�
pcolormesh�hist)r0r(r'r)r%�rtolr,r3�	plot_dims�ndims�	error_msgr1s            r�plotrE9s��J�^�^�
�
�F��F�K� � �I�
���c����
���c�����	�N�N�E�?�I�
��z�z��	(�#�	(��Y�'�'�'����	�!�����u�
���u�
�%��z�� +��}������	(�#�	(��Y�'�'�'����F�4�L��8�F�%�%�f�%�%�%rc���ddlm}t|j��}|dkr#t	d�|������|�dd��}|�|���}t|j	�
����d\}}t|g��|j||g|�Ri|��}|�
|��|�|�����|j�|�|j��t%j|jt$j��r&|������|S)a`
    Line plot of 1 dimensional DataArray index against values

    Wraps matplotlib.pyplot.plot

    Parameters
    ----------
    darray : DataArray
        Must be 1 dimensional
    ax : matplotlib axes, optional
        If not passed, uses the current axis
    *args, **kwargs : optional
        Additional arguments to matplotlib.pyplot.plot

    rNrzTLine plots are for 1 dimensional DataArrays. Passed DataArray has {ndims} dimensions)rCr%)�matplotlib.pyplot�pyplotr=r;r.�formatr-�gca�list�indexes�itemsr"rE�
set_xlabel�	set_title�_title_for_slice�name�
set_ylabelrrr
r�gcf�
autofmt_xdate)	r0r!r3�pltrCr%�xlabelr�	primitives	         rr>r>�sX�� $�#�#�#�#�#������E���z�z��&�&,�f�5�f�&9�&9�;�;�	;�

���D�$�	�	�B�	�z�
�W�W�Y�Y���V�^�)�)�+�+�,�,�Q�/�I�F�A��q�c��������6�3�D�3�3�3�F�3�3�I��M�M�&�����L�L��(�(�*�*�+�+�+�
�{��
�
�
�f�k�"�"�"�
�}�Q�W�b�m�,�,�"����	�	���!�!�!��rc�R�ddlm}|�|���}tj|j��}|t
j|��}|j|fi|��}|�	d��|j
�-|�d�|j
����|S)a|
    Histogram of DataArray

    Wraps matplotlib.pyplot.hist

    Plots N dimensional arrays by first flattening the array.

    Parameters
    ----------
    darray : DataArray
        Can be any dimension
    ax : matplotlib axes, optional
        If not passed, uses the current axis
    **kwargs : optional
        Additional keyword arguments to matplotlib.pyplot.hist

    rN�CountzHistogram of {0})
rGrHrJr�ravel�values�pd�notnullr@rRrQrOrI)r0r%r3rU�no_nanrWs      rr@r@�s���$$�#�#�#�#�#�	�z�
�W�W�Y�Y��
�X�f�m�
$�
$�F�
�B�J�v�&�&�
'�F�����)�)�&�)�)�I��M�M�'����
�{��
���'�.�.�v�{�;�;�<�<�<��rc���|�no|r5|�t|�������n8|s6|�t|���d�����|�dS|r6|�t|�������dS|s8|�t|���d�����dSdS)zM
    Update axes in place to increase or decrease
    For use in _plot2d
    NT)�reverse)�set_xlim�sorted�get_xlim�set_ylim�get_ylim)r%�	xincrease�	yincreases   r�_update_axes_limitsrh�s���
���	�9�
���F�2�;�;�=�=�)�)�*�*�*�*�
�9�
���F�2�;�;�=�=�$�7�7�7�8�8�8�����	�9�
���F�2�;�;�=�=�)�)�*�*�*�*�*�
�9�
���F�2�;�;�=�=�$�7�7�7�8�8�8�8�8�9�9rc��eZdZdZd�Zd�Zeje��dd���Zeje	��d���Z	dS)�_PlotMethodszs
    Enables use of xarray.plot functions as attributes on a DataArray.
    For example, DataArray.plot.imshow
    c��||_dSr
)�_da)�selfr0s  r�__init__z_PlotMethods.__init__�s
������rc�&�t|jfi|��Sr
)rErl)rmr3s  r�__call__z_PlotMethods.__call__�s���D�H�'�'��'�'�'rNc�*�t|jfd|i|��S)Nr%)r@rl)rmr%r3s   rr@z_PlotMethods.hist�s���D�H�.�.��.�v�.�.�.rc�,�t|jg|�Ri|��Sr
)r>rl)rmr!r3s   rr>z_PlotMethods.line�s"���D�H�.�t�.�.�.�v�.�.�.rr
)
�__name__�
__module__�__qualname__�__doc__rnrp�	functools�wrapsr@r>�rrrjrj�s���������
���(�(�(��Y�_�T���/�/�/���/��Y�_�T���/�/���/�/�/rrjc����d}d��j|f���_tj���					d�fd�	���tj���					d	�fd�	��}t	t
|j|���S)
zh
    Decorator for common 2d plotting logic

    Also adds the 2d plot method to class _PlotMethods
    a,

    Parameters
    ----------
    darray : DataArray
        Must be 2 dimensional, unless creating faceted plots
    x : string, optional
        Coordinate for x axis. If None use darray.dims[1]
    y : string, optional
        Coordinate for y axis. If None use darray.dims[0]
    ax : matplotlib axes object, optional
        If None, uses the current axis
    row : string, optional
        If passed, make row faceted plots on this dimension name
    col : string, optional
        If passed, make column faceted plots on this dimension name
    col_wrap : integer, optional
        Use together with ``col`` to wrap faceted plots
    xincrease : None, 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
    yincrease : None, 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_colorbar : Boolean, optional
        Adds colorbar to axis
    add_labels : Boolean, optional
        Use xarray metadata to label axes
    vmin, vmax : floats, 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.
    cmap : matplotlib 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 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.
    colors : discrete 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.
    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 list-like object, optional
        Split the colormap (cmap) into discrete color intervals.
    subplot_kws : dict, optional
        Dictionary of keyword arguments for matplotlib subplots. Only applies
        to FacetGrid plotting.
    **kwargs : optional
        Additional arguments to wrapped matplotlib function

    Returns
    -------
    artist :
        The same type of primitive artist that the wrapped matplotlib
        function returns
    �
NTFc
�P��|s|rpt�����}|�|�d����t	��� j|d<t
di|��Sddlm}|
r|rtd���|rd� jvr|std���t|
ttf��rtjdtd�	��|�|���}t#|||�
��\}}||j}||j}|�d���}||jdkr|j}t-||��d� jvr|�d
}|j|||r|n|
||||� jdkd�	}t1di|��}d� jvr|d|d<|d|d<|�d|d��� |||f||d|d|dd�|��\}}|
rQ|�|��|�|��|�|�����|	rC|�|||d���}|jr|
r|� |jd���tC|||��|S)Nr3r1rz#Can't specify both cmap and colors.�contourz.Can only specify colors with contour or levelszNSpecifying a list of colors in cmap is deprecated. Use colors keyword instead.r#)�
stacklevel)r0rr2F)�copy�)	�	plot_data�vmin�vmax�cmap�center�robust�extend�levels�filledr�r��normr�r�r�)r%r�r�r�)r%r��Z)�rotationry)"�localsr�updater-�globalsrsr5rGrHr.�
isinstancerK�tuple�warnings�warn�DeprecationWarningrJrr[�to_masked_arrayr;�Tr"r&r�
setdefaultrNrRrOrP�colorbarrQ�	set_labelrh)!r0rr2r%r(r'r)rfrg�add_colorbar�
add_labelsr�r�r�r�r�r�r��colorsr,r3�allargsrU�xlab�ylab�xval�yval�zval�cmap_kwargs�cmap_paramsrW�cbarr1s!                                �r�newplotfuncz_plot2d.<locals>.newplotfuncOs;����	.�#�	.��h�h�m�m�o�o�G��N�N�7�;�;�x�0�0�1�1�1�#*�)�)�H�,=�">�G�J��"�-�-�W�-�-�-�'�'�'�'�'�'��	D�F�	D��B�C�C�C��	O�	��):�:�:�V�:��M�N�N�N��d�T�5�M�*�*�	<��M�8�,��
<�
<�
<�
<��:������B�%�V�q�A�>�>�>�
��d��d�|�"���d�|�"���%�%�5�%�1�1���6�;�q�>�!�!��6�D��$��%�%�%���)�)�)�f�n��F�$(�I�#�#�)/�9�v�v�T�!'�!'�!'�!'�!)�!2�i�!?�	�	��-�;�;�{�;�;����)�)�)� +�8�4�F�8��*�8�4�F�8��	���&�+�f�"5�6�6�6� ���t�T�+�b�&1�&�&9�&1�&�&9�&1�&�&9�+�+�$*�	+�+�
��I��	4��M�M�$�����M�M�$�����L�L��0�0�2�2�3�3�3��	9��<�<�	�b��X�9N�<�O�O�D��{�
9�z�
9����v�{�R��8�8�8��B�	�9�5�5�5��rc�~��t��}|j|d<|�|��dD]}||=��di|��S)z�
        The method should have the same signature as the function.

        This just makes the method work on Plotmethods objects,
        and passes all the other arguments straight through.
        r0)�_PlotMethods_objr�r3ry)r�rlr�)r�rr2r%r(r'r)rfrgr�r�r�r�r�r�r�r�r�r�r,r3r��argr�s                       �r�
plotmethodz_plot2d.<locals>.plotmethod�s[����(�(��,�0�������v����@�	�	�C������{�%�%�W�%�%�%r)NNNNNNTTTTNNNNFNNNN)NNNNNNTTTTNNNNNFNNN)�joinrvrwrx�setattrrjrs)r1�	commondocr�r�s`  @r�_plot2dr�s�����C�I�L�y�y�(�"2�I�!>�?�?�H���_�X���CG�=A�HL�AE�:>�	_�_�_�_�_���_�D�_�[�!�!�BF�FJ�GK�?D�9=�	&�&�&�&�&�"�!�&�&�L�*�-�z�:�:�:��rc��|jdks|jdkrtd���|d|dz
dz}|d|dz
dz}|d|z
|d|z}}|d|z|d|z
}
}	|||	|
gddd�}t|d	��sd
|d<|�|��|j|fi|��}||fS)a�
    Image plot of 2d DataArray using matplotlib.pyplot

    Wraps matplotlib.pyplot.imshow

    ..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.
    rzBimshow requires 1D coordinates, try using pcolormesh or contour(f)rg@����upper�nearest)�extent�origin�
interpolation�
projection�autor*)�ndimr.�hasattrr��imshow)
rr2�zr%r3�xstep�ystep�left�right�bottom�top�defaultsrWs
             rr�r��s�� 	�v��{�{�a�f��k�k��4�5�5�	5��q�T�A�a�D�[�C��E�
�q�T�A�a�D�[�C��E��A�$��,��"���
�%�D��B�%�%�-��1����C�F�����4�!�!*���H�
�2�|�$�$�$�#����
�O�O�F������	�!�(�(�x�(�(�I�
�y�=�rc�*�|j|||fi|��}||fS)zK
    Contour plot of 2d DataArray

    Wraps matplotlib.pyplot.contour
    )r}�rr2r�r%r3rWs      rr}r}�s+����
�1�a��-�-�f�-�-�I�
�y�=�rc�*�|j|||fi|��}||fS)zS
    Filled contour plot of 2d DataArray

    Wraps matplotlib.pyplot.contourf
    )�contourfr�s      rr�r�s+�����A�q�!�.�.�v�.�.�I�
�y�=�rc���tj|��}d|dd�|dd�z
z}|d|dz
}|d|dz}tj|g|dd�|z|gfS)zb
    >>> _infer_interval_breaks(np.arange(5))
    array([-0.5,  0.5,  1.5,  2.5,  3.5,  4.5])
    g�?rNr�r)r�asarray�r_)�coord�deltas�first�lasts    r�_infer_interval_breaksr�s{��

�J�u���E�
�E�!�"�"�I��c�r�c�
�*�
+�F��!�H�v�a�y� �E���9�v�b�z�!�D�
�5�%��%����*�v�-��v�5�6�6rc�:�t|��}t|��}|j|||fi|��}t|d��sZ|jdkrO|jdkrD|�|d|d��|�|d|d��||fS)zR
    Pseudocolor plot of 2d DataArray

    Wraps matplotlib.pyplot.pcolormesh
    r�rrr�)r�r?r�r�rardr�s      rr?r?s���	�q�!�!�A��q�!�!�A���
�a��A�0�0��0�0�I��2�|�$�$�!���1�����1���
���A�a�D�!�B�%� � � �
���A�a�D�!�B�%� � � �
�y�=�r)NNNrr#N)NNNNr6Nr
)rv�
__future__rrwr��numpyr�pandasr\�utilsrr�	facetgridrrr"r5rEr>r@rh�objectrjr�r�r}r�r�r?ryrr�<module>r�s����� ����������������������;�;�;�;�;�;�;�;� � � � � � �;�;�;�
%�
%�
%�JN�26�
5�
5�
5�
5� CG��C&�C&�C&�C&�P.�.�.�b!�!�!�!�H9�9�9�,/�/�/�/�/�6�/�/�/�*G�G�G�T	�'�'�	��'�T	���	���	���	���	7�	7�	7�	���	����r