
    zYHho.                         d dl Z d dlZd dlmZmZmZ d dlmZ	 d dl
mZmZ d dlmZ d dlmZ  G d de      ZdZej&                  j)                  e	       y)
    N)_api
_docstring
transforms)	_AxesBase_TransformedBoundsLocator)Axis)	Transformc                        e Zd ZdZd fd	Zd Zd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                  j                  d      }| j                  dk(  r7t        	|    |g dfi | | j                  | _
        ddg| _        d	d
g| _        n6t        	|    |g dfi | | j                  | _
        d
d	g| _        ddg| _        d| _        | j                  ||       | j!                  |       | j                  dk(  r| j                  n| j                  }|j#                  t%        j&                                |j)                  d       | j*                  | j                     j-                  d       | j*                  | j                     j-                  d       | j.                  dk  r| j                  ddd   | _        | j1                  | j                  d          y)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)root)r         ?   -C6?topbottomleftright)r   r   r   r   NnoneTg      ?r   )r   check_in_list
_functions_parent_orientation
_ticks_set
get_figuresuper__init__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	transformkwargsfig	otheraxis	__class__s
            X/var/www/html/planif/env/lib/python3.12/site-packages/matplotlib/axes/_secondary_axes.pyr!   zSecondaryAxis.__init__   s    	C:;?#'ll%%5%1#GS"4??DJ %x0D"('!2DGS"4??DJ '0D"'!2D  	(I.9% #'"3"3s":DJJ

	##G$7$7$9:$$V,D&&'33E:D$$%11$799s?#//"5D4++A./    c                    t        j                  | j                  |       || j                  d   k(  r| j                  ddd   | _        | j                  | j                  d      j	                  d       | j                  | j                  d      j	                  d       | j
                  j                  |       | j
                  j                  |       y)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)r2   r>   s     r;   r1   zSecondaryAxis.set_alignment<   s     	4++59D$$Q''#//"5DD$$Q'(44T:D$$Q'(44U;

%%e,

%%e,r<   c                    t        j                  t        j                  df|       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}|gt        j                  | j                  j                   |      }n<| j                  ddd
g}|*t        j                  || j                  j                         }|| j                  j                   }| j#                  t%        ||             y)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).

        transform : `.Transform`, optional
            Transform for the location to use. Defaults to
            the parent's ``transAxes``, so locations are normally relative to
            the parent axes.

            .. versionadded:: 3.9
        N)r6   )r4   )r   r   r   g        zlocation must be r   z, r   z, or a float, not r   g|=)r   check_isinstancer   r	   
isinstancestrr   r$   r0   numbersReal
ValueError_locr   blended_transform_factoryr   	transAxesset_axes_locatorr   )r2   r4   r6   boundss       r;   r(   zSecondaryAxis.set_locationO   sc   , 	z33T:iP h$t//(C&*::DI',,/ DI#D$4$4Q$7#:"##A&));H<IJ J 	# B.F
 $&@@LL**I7	 iiE1-F$&@@t||557	 ..I 	7	JKr<   c                 D    | j                          t        | 	  |       y N)	_set_limsr    apply_aspect)r2   positionr:   s     r;   rO   zSecondaryAxis.apply_aspect   s    X&r<   F)minorc                b     | j                   j                  ||fd|i|}d| _        d| _        |S )NrQ   T)r#   	set_ticksstaler   )r2   tickslabelsrQ   r7   rets         r;   rS   zSecondaryAxis.set_ticks   s7    "djj""5&HHH

r<   c                 *   t        t              r2t              dk(  r$t        d         rt        d         r| _        n@t        t
              rj                  fdf| _        nd d f| _        nt        d      | j                          y)	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   c                 B    j                         j                  |       S rM   )invertedr6   )r   r5   s    r;   <lambda>z-SecondaryAxis.set_functions.<locals>.<lambda>   s    9--/99!< r<   Nc                     | S rM    r   s    r;   r\   z-SecondaryAxis.set_functions.<locals>.<lambda>   s     r<   c                     | S rM   r^   r_   s    r;   r\   z-SecondaryAxis.set_functions.<locals>.<lambda>   s    a r<   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)	rB   tuplelencallabler   r	   r6   rF   
_set_scale)r2   r5   s    `r;   r)   zSecondaryAxis.set_functions   s    $ y%(S^q-@1&8IaL+A (DO	9-$$<DO *K8DO @ A A 	r<   c                 d    | j                          | j                          t        |   |       y)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)rN   rd   r    draw)r2   rendererr:   s     r;   rf   zSecondaryAxis.draw   s%     	Xr<   c                    | j                   dk(  r1| j                  j                  j                         }| j                  }n0| j                  j
                  j                         }| j                  }|| j                  k(  ry| j                  r| j                  j                         } ||dk(  rdnd| j                  ddd          | j                  r.| j                  j                  t        j                               || _        y)z3
        Check if parent has set its scale
        r   Nlogfunctionlogfunctionr   )r5   )r   r   r"   	get_scale
set_xscaler&   
set_yscaler'   r   r#   get_ticklocsr   r*   r+   FixedLocator)r2   pscale	set_scalerU   s       r;   rd   zSecondaryAxis._set_scale   s    
 #\\''113FI\\''113FIT&&&??JJ++-E 	6U?-
 OODbD1	3
 ??JJ(()=)=e)DE #r<   c                 b   | j                   dk(  r'| j                  j                         }| j                  }n&| j                  j	                         }| j
                  }|d   |d   k  } | j                  d   t        j                  |            }|d   |d   k  }||k7  r|ddd   } ||       y)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)r2   limsset_limorderneworders        r;   rN   zSecondaryAxis._set_lims   s    
 #<<((*DmmG<<((*DmmGQ$q'!!tq!"((4.17T!W$u":Dr<   c                 .    t        j                  d       y)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)r2   argsr7   s      r;   
set_aspectzSecondaryAxis.set_aspect   s    
 	FGr<   c                    | j                   | j                     }|j                  |       | j                  j	                         D ]"  }|j
                  |u s|j                  |       $ |j                  j                  |       y)z
        Change the color of the secondary Axes and all decorators.

        Parameters
        ----------
        color : :mpltype:`color`
        )colorsN)	_axis_mapr   set_tick_paramsr.   valuesaxis	set_colorlabel)r2   colorr   spines       r;   r   zSecondaryAxis.set_color  sq     ~~d//0E*[['') 	'EzzT!&	' 	

U#r<   rM   )__name__
__module____qualname____doc__r!   r1   r(   rO   r   copyr   rS   r)   rf   rd   rN   r   r   __classcell__)r:   s   @r;   r   r      si    )0V-&>L@'
 Z__T^^$U  %#J#:&H$r<   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.

transform : `.Transform`, optional
    If specified, *location* will be
    placed relative to this transform (in the direction of the axis)
    rather than the parent's axis. i.e. a secondary x-axis will
    use the provided y transform and the x transform of the parent.

    .. versionadded:: 3.9

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

Other Parameters
----------------
**kwargs : `~matplotlib.axes.Axes` properties.
    Other miscellaneous Axes parameters.
)_secax_docstring)rD   numpyrx   
matplotlibr   r   r   matplotlib.tickertickerr+   matplotlib.axes._baser   r   matplotlib.axisr   matplotlib.transformsr	   r   r   interpdregisterr^   r<   r;   <module>r      sO      3 3 # F   +F$I F$R, Z     -=  >r<   