
    (?e(                         d dl Z 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e
          ZdZej                            e           dS )	    N)_api
_docstring)	_AxesBase_TransformedBoundsLocator)Axisc                        e Zd ZdZ fdZd Zd Zd fd	Z ej	        e
j                  dddd	            Zd
 Z fdZd Zd Zd Zd Z xZS )SecondaryAxisz4
    General class to hold a Secondary_X/Yaxis.
    c                    t          j        ddg|           || _        || _        || _        d| _        | j        dk    rF t                      j        | j        j        g dfi | | j	        | _
        ddg| _        dd	g| _        nE t                      j        | j        j        g d
fi | | j        | _
        d	dg| _        ddg| _        d| _        |                     |           |                     |           | j        dk    r| j        n| j	        }|                    t%          j                               |                    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.
        xy)orientationF)r         ?   -C6?topbottomleftright)r   r   r   r   NnoneTg      ?r   )r   check_in_list
_functions_parent_orientation
_ticks_setsuper__init__figurexaxis_axis_locstrings_otherstringsyaxis_parentscaleset_locationset_functionsset_major_locatormtickerNullLocatorset_ticks_positionspinesset_visible_posset_alignment)selfparentr   location	functionskwargs	otheraxis	__class__s          ?lib/python3.11/site-packages/matplotlib/axes/_secondary_axes.pyr   zSecondaryAxis.__init__   s    	C:;????#'##EGGT\02D2D2DOOOOODJ %x0D"('!2DEGGT\02D2D2DOOOOODJ '0D"'!2D  	(###9%%% #'"3s":":DJJ
	##G$7$9$9:::$$V,,,D&'33E:::D$%11$7779s??#/"5D4+A./////    c                    t          j        | j        |           || j        d         k    r| 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 : {'top', 'bottom', 'left', 'right'}
            Either 'top' or 'bottom' for orientation='x' or
            'left' or 'right' for orientation='y' axis.
        )alignr   Nr   r   TF)r   r   r!   r+   r,   r    r*   set_label_position)r/   r9   s     r6   r.   zSecondaryAxis.set_alignment9   s     	4+59999D$Q'''#/"5DD$Q'(44T:::D$Q'(44U;;;
%%e,,,
%%e,,,,,r7   c                    t          |t                    r)t          j        | j        |           |dv rdnd| _        nPt          |t          j                  r|| _        n.t          d| j        d         d| j        d         d	|          || _	        | j
        d
k    rd| 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).
        )r1   )r   r   r   g        zlocation must be r   z, r   z, or a float, not r   g|=N)
isinstancestrr   r   r!   r-   numbersReal
ValueError_locr   set_axes_locatorr   r   	transAxes)r/   r1   boundss      r6   r%   zSecondaryAxis.set_locationL   s3     h$$ 	Jt/(CCCC&*:::DII',// 	J DIIID$4Q$7 I I#A&I I<DI IJ J J 	## B.FFiE1-F 	%fdl.DEE	G 	G 	G 	G 	Gr7   Nc                 r    |                                   t                                          |           d S N)	_set_limsr   apply_aspect)r/   positionr5   s     r6   rH   zSecondaryAxis.apply_aspectv   s1    X&&&&&r7   F)minorc                N     | j         j        ||fd|i|}d| _        d| _        |S )NrJ   T)r    	set_ticksstaler   )r/   tickslabelsrJ   r3   rets         r6   rL   zSecondaryAxis.set_ticks{   s8    "dj"5&HHHHH

r7   c                    t          |t                    rEt          |          dk    r2t          |d                   rt          |d                   r|| _        n|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 rF    r   s    r6   <lambda>z-SecondaryAxis.set_functions.<locals>.<lambda>   s     r7   c                     | S rF   rT   rU   s    r6   rV   z-SecondaryAxis.set_functions.<locals>.<lambda>   s    a r7   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)r<   tuplelencallabler   r@   
_set_scale)r/   r2   s     r6   r&   zSecondaryAxis.set_functions   s    " y%(( 	AS^^q-@-@1&& .A+3IaL+A+A .A (DOO*{KK8DOO @ A A A 	r7   c                     |                                   |                                  t                                          |           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)rG   r[   r   draw)r/   rendererr5   s     r6   r]   zSecondaryAxis.draw   sA     	Xr7   c                    | j         dk    r&| j        j                                        }| j        }n%| j        j                                        }| j        }|| j        k    rdS | j        r| j	        
                                } ||dk    rdnd| j        ddd                    | j        r,| j	                            t          j        |                     || _        dS )z3
        Check if parent has set its scale
        r   Nlogfunctionlogfunctionr   )r2   )r   r   r   	get_scale
set_xscaler#   
set_yscaler$   r   r    get_ticklocsr   r'   r(   FixedLocator)r/   pscale	set_scalerN   s       r6   r[   zSecondaryAxis._set_scale   s    
 ##\'1133FII\'1133FIT&&&F? 	.J++--E 		6U??--
 ODDbD1	3 	3 	3 	3
 ? 	FJ(()=e)D)DEEE #r7   c                 n   | j         dk    r!| j                                        }| j        }n | j                                        }| j        }|d         |d         k     } | j        d         t          j        |                    }|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   Nr   )	r   r   get_xlimset_xlimget_ylimset_ylimr   nparray)r/   limsset_limorderneworders        r6   rG   zSecondaryAxis._set_lims   s    
 ##<((**DmGG<((**DmGQ$q'!!tq!"(4..117T!W$u":Dr7   c                 .    t          j        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_external)r/   argsr3   s      r6   
set_aspectzSecondaryAxis.set_aspect   s    
 	FGGGGGr7   c                     | j         | j                 }|                    |           | j                                        D ] }|j        |u r|                    |           !|j                            |           dS )z
        Change the color of the secondary axes and all decorators.

        Parameters
        ----------
        color : color
        )colorsN)	_axis_mapr   set_tick_paramsr+   valuesaxis	set_colorlabel)r/   colorr~   spines       r6   r   zSecondaryAxis.set_color   s     ~d/0E***['')) 	' 	'EzT!!&&&
U#####r7   rF   )__name__
__module____qualname____doc__r   r.   r%   rH   r   copyr   rL   r&   r]   r[   rG   rx   r   __classcell__)r5   s   @r6   r	   r	      s%        '0 '0 '0 '0 '0R- - -&(G (G (GT' ' ' ' ' '
 Z_T^$$U     %$  >    # # #:  &H H H$ $ $ $ $ $ $r7   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)r>   numpyro   
matplotlibr   r   matplotlib.tickertickerr(   matplotlib.axes._baser   r   matplotlib.axisr   r	   r   interpdupdaterT   r7   r6   <module>r      s         ' ' ' ' ' ' ' ' # # # # # # F F F F F F F F            h$ h$ h$ h$ h$I h$ h$ h$V$ J    +;  < < < < <r7   