a
    Sic|)                     @   sf   d dl Zd dlmZ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
_docstring)	_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rt 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mtickerNullLocatorset_ticks_positionspinesset_visible_posset_alignment)selfparentorientationlocation	functionskwargsZ	otheraxis	__class__ [/var/www/html/django/DPS/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   check_in_listr   r%   r&   r   r$   set_label_position)r)   r3   r1   r1   r2   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   _locr   set_axes_locatorr   r   	transAxes)r)   r,   boundsr1   r1   r2   r   N   s(    

zSecondaryAxis.set_locationNc                    s   |    t | d S N)	_set_limsr   apply_aspect)r)   positionr/   r1   r2   r?   y   s    zSecondaryAxis.apply_aspectF)minorc                K   s*   | j j||fd|i|}d| _d| _|S )NrA   T)r   	set_ticksstaler   )r)   tickslabelsrA   r.   retr1   r1   r2   rB   ~   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 r=   r1   )r   r1   r1   r2   <lambda>       z-SecondaryAxis.set_functions.<locals>.<lambda>zfunctions 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)r6   tuplelencallabler   r8   
_set_scale)r)   r-   r1   r1   r2   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)r>   rM   r   drawr)   argsr.   r/   r1   r2   rN      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logfunctionlogfunctionr   )r-   )r   r   r   	get_scale
set_xscaler   
set_yscaler   r   r   get_ticklocsr   r!   r"   FixedLocator)r)   Zpscale	set_scaleZdefscalerD   r1   r1   r2   rM      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   get_xlimset_xlimget_ylimset_ylimr   nparray)r)   limsZset_limorderZneworderr1   r1   r2   r>      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   warn_externalrO   r1   r1   r2   
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   )axiscolorsr   N)r   tick_paramsr%   r   	set_colorr   r   labelr   r   r   )r)   colorr1   r1   r2   rg      s    
zSecondaryAxis.set_color)N)N)__name__
__module____qualname____doc__r   r(   r   r?   r   copyr   rB   r    rN   rM   r>   rc   rg   __classcell__r1   r1   r/   r2   r   	   s   -+
!!r   a  
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. Both functions must accept
    numpy arrays as input.

    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)numpyr^   
matplotlibr   r   matplotlib.tickertickerr"   matplotlib.axes._baser   r   matplotlib.axisr   r   rp   interpdupdater1   r1   r1   r2   <module>   s    {%