a
    ëÝEba)  ã                   @   sn   d dl Zd dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ G dd„ de
ƒZdZejjed� dS )	é    N)Ú_api)Ú	_AxesBaseÚ_TransformedBoundsLocator)ÚAxisc                       sŽ   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zd‡ fd	d
„	Ze 	e
j¡dddœdd„ƒZdd„ Z‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚSecondaryAxisz4
    General class to hold a Secondary_X/Yaxis.
    c                    sB  || _ || _|| _d| _| jdkr^tƒ j| jjg d¢fi |¤Ž | j| _ddg| _	ddg| _
nD| jdkr¢tƒ j| jjg d	¢fi |¤Ž | j| _ddg| _	ddg| _
d
| _|  |¡ |  |¡ | jdkrÎ| j}n| j}| t ¡ ¡ | d¡ | j| j
  d¡ | j| j	  d¡ | jdk �r.| j	d
d
d… | _	|  | j	d ¡ d
S )zÎ
        See `.secondary_xaxis` and `.secondary_yaxis` for the doc string.
        While there is no need for this to be private, it should really be
        called by those higher level functions.
        FÚx)r   ç      ð?é   ç-Cëâ6?ÚtopÚbottomÚleftÚrightÚy)r   r   r
   r	   NÚnoneTg      à?éÿÿÿÿr   )Ú
_functionsÚ_parentÚ_orientationÚ
_ticks_setÚsuperÚ__init__ÚfigureÚxaxisÚ_axisÚ_locstringsZ_otherstringsÚyaxisÚ_parentscaleÚset_locationÚset_functionsÚset_major_locatorÚmtickerZNullLocatorÚset_ticks_positionÚspinesÚset_visibleÚ_posÚset_alignment)ÚselfÚparentZorientationÚlocationÚ	functionsÚkwargsZ	otheraxis©Ú	__class__© ú_/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/axes/_secondary_axes.pyr      s6    








zSecondaryAxis.__init__c                 C   sx   t j| j|d� || jd kr0| jddd… | _| j| jd   d¡ | j| jd   d¡ | j |¡ | j |¡ dS )a  
        Set if axes spine and labels are drawn at top or bottom (or left/right)
        of the axes.

        Parameters
        ----------
        align : str
            either 'top' or 'bottom' for orientation='x' or
            'left' or 'right' for orientation='y' axis.
        )Úalignr	   Nr   r   TF)r   Zcheck_in_listr   r#   r$   r   r"   Zset_label_position)r'   r0   r.   r.   r/   r&   <   s    zSecondaryAxis.set_alignmentc                 C   sž   t |tƒrR|dv rd| _qX|dv r*d| _qXtd| jd ›d| jd ›d	|›�ƒ‚n|| _|| _| jd
krxd| jddg}n| jdddg}|  t|| j	j
ƒ¡ dS )a+  
        Set the vertical or horizontal location of the axes in
        parent-normalized coordinates.

        Parameters
        ----------
        location : {'top', 'bottom', 'left', 'right'} or float
            The position to put the secondary axis.  Strings can be 'top' or
            'bottom' for orientation='x' and 'right' or 'left' for
            orientation='y'. A float indicates the relative position on the
            parent axes to put the new axes, 0.0 being the bottom (or left)
            and 1.0 being the top (or right).
        )r   r   r   )r   r   g        zlocation must be r   z, r	   z, or a float, not r   g»½×Ùß|Û=N)Ú
isinstanceÚstrr%   Ú
ValueErrorr   Z_locr   Zset_axes_locatorr   r   Z	transAxes)r'   r)   Zboundsr.   r.   r/   r   O   s(    
ÿÿÿ
ÿzSecondaryAxis.set_locationNc                    s   |   ¡  tƒ  |¡ d S ©N)Ú	_set_limsr   Úapply_aspect)r'   Úpositionr,   r.   r/   r6   z   s    zSecondaryAxis.apply_aspectF)Úminorc                K   s*   | j j||fd|i|¤Ž}d| _d| _|S )Nr8   T)r   Ú	set_ticksÚstaler   )r'   ÚticksÚlabelsr8   r+   Úretr.   r.   r/   r9      s    zSecondaryAxis.set_ticksc                 C   sf   t |tƒr6t|ƒdkr6t|d ƒr6t|d ƒr6|| _n$|du rRdd„ dd„ f| _ntdƒ‚|  ¡  dS )a&  
        Set how the secondary axis converts limits from the parent axes.

        Parameters
        ----------
        functions : 2-tuple of func, or `Transform` with an inverse.
            Transform between the parent axis values and the secondary axis
            values.

            If supplied as a 2-tuple of functions, the first function is
            the forward transform function and the second is the inverse
            transform.

            If a transform is supplied, then the transform must have an
            inverse.
        é   r   r	   Nc                 S   s   | S r4   r.   )r   r.   r.   r/   Ú<lambda>�   ó    z-SecondaryAxis.set_functions.<locals>.<lambda>z›functions argument of secondary axes must be a two-tuple of callable functions with the first function being the transform and the second being the inverse)r1   ÚtupleÚlenÚcallabler   r3   Ú
_set_scale)r'   r*   r.   r.   r/   r   †   s    
ÿ
ÿzSecondaryAxis.set_functionsc                    s&   |   ¡  |  ¡  tƒ j|i |¤Ž dS )zÿ
        Draw the secondary axes.

        Consults the parent axes for its limits and converts them
        using the converter specified by
        `~.axes._secondary_axes.set_functions` (or *functions*
        parameter when axes initialized.)
        N)r5   rD   r   Údraw©r'   Úargsr+   r,   r.   r/   rE   §   s    	zSecondaryAxis.drawc                 C   s¢   | j dkr| jj ¡ }| j}| j dkr8| jj ¡ }| j}|| jkrFdS |dkrTd}nd}| jrh| j	 
¡ }||| jddd… d� | jr˜| j	 t |¡¡ || _dS )	z3
        Check if parent has set its scale
        r   r   NÚlogZfunctionlogÚfunctionr   )r*   )r   r   r   Z	get_scaleZ
set_xscaler   Z
set_yscaler   r   r   Zget_ticklocsr   r    r!   ZFixedLocator)r'   ZpscaleZ	set_scaleZdefscaler;   r.   r.   r/   rD   µ   s"    



zSecondaryAxis._set_scalec                 C   sŠ   | j dkr| j ¡ }| j}| j dkr4| j ¡ }| j}|d |d k }| jd t |¡ƒ}|d |d k }||kr~|ddd… }||ƒ dS )z‚
        Set the limits based on parent limits and the convert method
        between the parent and this secondary axes.
        r   r   r   r	   Nr   )	r   r   Zget_xlimZset_xlimZget_ylimZset_ylimr   ÚnpÚarray)r'   ZlimsZset_limÚorderZneworderr.   r.   r/   r5   Ö   s    



zSecondaryAxis._set_limsc                 O   s   t  d¡ dS )zj
        Secondary axes cannot set the aspect ratio, so calling this just
        sets a warning.
        z)Secondary axes can't set the aspect ratioN)r   Zwarn_externalrF   r.   r.   r/   Ú
set_aspecté   s    zSecondaryAxis.set_aspectc                 C   s€   | j dkrD| jd|d� | jj |¡ | jj |¡ | jj |¡ n8| jd|d� | jj |¡ | jj	 |¡ | j
j |¡ dS )z‰
        Change the color of the secondary axes and all decorators.

        Parameters
        ----------
        color : color
        r   )ZaxisÚcolorsr   N)r   Ztick_paramsr#   r   Ú	set_colorr   r   Úlabelr   r   r   )r'   Úcolorr.   r.   r/   rO   ð   s    
zSecondaryAxis.set_color)N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r&   r   r6   Ú	docstringÚcopyr   r9   r   rE   rD   r5   rM   rO   Ú__classcell__r.   r.   r,   r/   r   
   s   -+
!!r   ao  
Warnings
--------
This method is experimental as of 3.1, and the API may change.

Parameters
----------
location : {'top', 'bottom', 'left', 'right'} or float
    The position to put the secondary axis.  Strings can be 'top' or
    'bottom' for orientation='x' and 'right' or 'left' for
    orientation='y'. A float indicates the relative position on the
    parent axes to put the new axes, 0.0 being the bottom (or left)
    and 1.0 being the top (or right).

functions : 2-tuple of func, or Transform with an inverse

    If a 2-tuple of functions, the user specifies the transform
    function and its inverse.  i.e.
    ``functions=(lambda x: 2 / x, lambda x: 2 / x)`` would be an
    reciprocal transform with a factor of 2.

    The user can also directly supply a subclass of
    `.transforms.Transform` so long as it has an inverse.

    See :doc:`/gallery/subplots_axes_and_figures/secondary_axis`
    for examples of making these conversions.

Returns
-------
ax : axes._secondary_axes.SecondaryAxis

Other Parameters
----------------
**kwargs : `~matplotlib.axes.Axes` properties.
    Other miscellaneous axes parameters.
)Ú_secax_docstring)ÚnumpyrJ   Z
matplotlibr   Zmatplotlib.docstringrV   Zmatplotlib.tickerZtickerr!   Zmatplotlib.axes._baser   r   Zmatplotlib.axisr   r   rY   ZinterpdÚupdater.   r.   r.   r/   Ú<module>   s    {$