
    \cg$                         d dl mZmZ d dlmZ d dlmZ d dlm	Z	 ddl
mZ  G d d      Z ej                  ed      Z ee      Z G d	 d
      Z ej                  edd      xZZ ee      xZZedddZeZy)    )_apicbookN)Bbox   )Axesc                   V     e Zd Zd
dd fdZ fdZ fdZ fdZd Zd Zd	 Z	 xZ
S )ParasiteAxesBaseN)viewlim_modec                    || _         || _        | j                  |       d|d<   t        |   |j                  d      |j                  fi | y )NFframeon)root)_parent_axestransAuxset_viewlim_modesuper__init__
get_figure	_position)selfparent_axesaux_transformr
   kwargs	__class__s        `/var/www/html/bid-api/venv/lib/python3.12/site-packages/mpl_toolkits/axes_grid1/parasite_axes.pyr   zParasiteAxesBase.__init__
   sX    '%l+!y//U/;$..	:28	:    c                 b   t         |           t        j                  | j	                         d       | j
                  j                  | _        | j
                  j                  j                  d| j                         | j
                  j                  j                  d| j                         y )NF)visiblexlim_changedylim_changed)
r   clearmartistsetpget_childrenr   
_get_lines	callbacks_connect_picklable
_sync_limsr   r   s    r   r    zParasiteAxesBase.clear   s|    T&&(%8++66##66DOO	-##66DOO	-r   c                     t         |   |       | j                         D ]C  }t        |j                  d      s| |j                  j
                  v s3|j                  |       E y )N	parasites)r   pickr#   hasattrinaxesr*   r   
mouseeventar   s      r   r+   zParasiteAxesBase.pick   sV     	Z  ""$A
));7
 1 1 ; ;;z" %r   c                 ~   | j                   | j                  j                  | _        | j                   | j                  j                  z   | _        t	        j
                  | j                  | j                        | _        t	        j
                  | j                  | j                        | _        y t        | %          y N)
r   r   	transAxes	transDatamtransformsblended_transform_factory_xaxis_transform_yaxis_transformr   _set_lim_and_transformsr(   s    r   r9   z(ParasiteAxesBase._set_lim_and_transforms*   s    ==$!..88DN!]]T->->-H-HHDN$/$I$I%0D!$/$I$I%0D! G+-r   c                 D    t        j                  g d|       || _        y )NNequal	transformmode)r   check_in_list_viewlim_mode)r   r?   s     r   r   z!ParasiteAxesBase.set_viewlim_mode5   s    7dC!r   c                     | j                   S r2   )rA   )r   s    r   get_viewlim_modez!ParasiteAxesBase.get_viewlim_mode9   s    !!!r   c                 b   |j                   j                         }| j                         }|y |dk(  r| j                   j                  |       y |dk(  rC| j                   j                  |j	                  | j
                  j                                      y t        j                  g d|       y )Nr<   r=   r;   r>   )	viewLimfrozenrC   settransformedr   invertedr   r@   )r   parentviewlimr?   s       r   r'   zParasiteAxesBase._sync_lims<   s    ..'')$$&<W_LLW%[ LLW001G1G1IJK;$Gr   r2   )__name__
__module____qualname__r   r    r+   r9   r   rC   r'   __classcell__r   s   @r   r	   r	      s/    :!%:-
#	.""
Hr   r	   z
{}Parasitec                   ~     e Zd Z fdZ	 ddZ fdZ fdZ fdZddZddZ	dd	Z
d
 Zd Zdddd fdZ xZS )HostAxesBasec                 2    g | _         t        |   |i | y r2   )r*   r   r   )r   argsr   r   s      r   r   zHostAxesBase.__init__Q   s    $)&)r   Nc                     || j                   }t        |      } || |fd|i|}| j                  j                  |       | j                  j                  |_        |S )ad  
        Add a parasite axes to this host.

        Despite this method's name, this should actually be thought of as an
        ``add_parasite_axes`` method.

        .. versionchanged:: 3.7
           Defaults to same base axes class as host axes.

        Parameters
        ----------
        tr : `~matplotlib.transforms.Transform` or None, default: None
            If a `.Transform`, the following relation will hold:
            ``parasite.transData = tr + host.transData``.
            If None, the parasite's and the host's ``transData`` are unrelated.
        viewlim_mode : {"equal", "transform", None}, default: "equal"
            How the parasite's view limits are set: directly equal to the
            parent axes ("equal"), equal after application of *tr*
            ("transform"), or independently (None).
        axes_class : subclass type of `~matplotlib.axes.Axes`, optional
            The `~.axes.Axes` subclass that is instantiated.  If None, the base
            class of the host axes is used.
        **kwargs
            Other parameters are forwarded to the parasite axes constructor.
        r
   )_base_axes_classparasite_axes_class_factoryr*   appendremove_remove_method)r   trr
   
axes_classr   parasite_axes_classax2s          r   get_aux_axeszHostAxesBase.get_aux_axesU   sj    6 ..J9*E!";#/;39; 	c"!^^22
r   c                    t        | j                        }| j                         }|r. || |      }| j                  |d       | j	                  |       n| j	                          | j                         }| j                  D ]<  }|j	                  |       | j                  j                  |j                                > t        | )  |       | j                  |d = y )Nactive)which)len	_childrenget_axes_locatorset_positionapply_aspectget_positionr*   extendr#   r   draw)r   rendererorig_children_lenlocatorposrectaxr   s          r   rj   zHostAxesBase.draw{   s    /'')$)Cc2c"  "..BOOD!NN!!"//"34 ! 	XNN,-.r   c                 d    t         |           | j                  D ]  }|j                           y r2   )r   r    r*   )r   rp   r   s     r   r    zHostAxesBase.clear   s#    ..BHHJ !r   c                 h    t         |   |       | j                  D ]  }|j                  |        y r2   )r   r+   r*   r.   s      r   r+   zHostAxesBase.pick   s+    Z  AFF:  r   c                     | j                  ||       }| j                  d   j                  d       |j                  d   j                  d       |j                  d   j                  d       |S )z
        Create a twin of Axes with a shared x-axis but independent y-axis.

        The y-axis of self will have ticks on the left and the returned axes
        will have ticks on the right.
        )sharexrightFT)lefttopbottom_add_twin_axesaxisset_visibler   r\   rp   s      r   twinxzHostAxesBase.twinx   sd       D 9		'&&u-
$$T*
'(44U;	r   c                     | j                  ||       }| j                  d   j                  d       |j                  d   j                  d       |j                  d   j                  d       |S )z
        Create a twin of Axes with a shared y-axis but independent x-axis.

        The x-axis of self will have ticks on the bottom and the returned axes
        will have ticks on the top.
        )shareyrw   FT)rv   ru   rx   ry   r}   s      r   twinyzHostAxesBase.twiny   sc       D 9		%$$U+
""4(
)*66u=	r   c                    |t        j                         }| j                  ||d      }| j                  d   j	                  d       |j                  d   j	                  d       |j                  d   j	                  d       |S )z
        Create a twin of Axes with no shared axis.

        While self will have ticks on the left and bottom axis, the returned
        axes will have ticks on the top and right axis.
        r=   )r   r
   )rw   ru   FT)rv   rx   )r5   IdentityTransformrz   r{   r|   )r   	aux_transr\   rp   s       r   twinzHostAxesBase.twin   s     #557I  ik ! K		.!--e4
++D1
 !--e4	r   c                     || j                   } t        |      | fi |}| j                  j                  |       | j                  |_        |S )zy
        Helper for `.twinx`/`.twiny`/`.twin`.

        *kwargs* are forwarded to the parasite axes constructor.
        )rV   rW   r*   rX   _remove_any_twinrZ   )r   r\   r   rp   s       r   rz   zHostAxesBase._add_twin_axes   sQ     ..J4(4TDVDb! 11	r   c                 V   | j                   j                  |       ddg}|j                  r|j                  d       |j                  r|j                  d       | j                  t        |         j                  d       | j                  t        |         j                  dd       y )Nrw   ru   TF)
ticklabelslabel)r*   rY   _sharex_shareyr{   tupler|   toggle)r   rp   restores      r   r   zHostAxesBase._remove_any_twin   s    b!'"::NN5!::NN7#		%.!--d3		%.!((E(Gr   Tcall_axes_locatorbbox_extra_artistsc                   g | j                   D cg c]  }|j                  ||       c}t        |   |||      }t        j                  |D cg c]#  }|j
                  dk7  s|j                  dk7  s"|% c}      S c c}w c c}w )N)r   r   r   )r*   get_tightbboxr   r   unionwidthheight)r   rk   r   r   rp   bbsbr   s          r   r   zHostAxesBase.get_tightbbox   s    J(&" x;LM&(J G!(4E5G " IJ zzcKcQWW\QXX]1cKLL(
 Ls   B#B8B)Nr<   Nr2   )NN)rL   rM   rN   r   r_   rj   r    r+   r~   r   r   rz   r   r   rO   rP   s   @r   rR   rR   P   sT    *
 =A$L/&
 HM)-M Mr   rR   z
{}HostAxesrV   )r\   figurec                     ddl m} t        |       }||j                         } ||g|i |}|j	                  |       |S )aP  
    Create axes that can act as a hosts to parasitic axes.

    Parameters
    ----------
    figure : `~matplotlib.figure.Figure`
        Figure to which the axes will be added. Defaults to the current figure
        `.pyplot.gcf()`.

    *args, **kwargs
        Will be passed on to the underlying `~.axes.Axes` object creation.
    r   N)matplotlib.pyplotpyplothost_axes_class_factorygcfadd_axes)r\   r   rT   r   plthost_axes_classrp   s          r   	host_axesr      sF     $-j9O~		1$	1&	1B
OOBIr   )
matplotlibr   r   matplotlib.artistartistr!   matplotlib.transforms
transformsr5   r   mpl_axesr   r	   _make_class_factoryrW   ParasiteAxesrR   r   host_subplot_class_factoryHostAxesSubplotHostr   host_subplot r   r   <module>r      s    " # + & >H >HF 8e77l$ *40SM SMn ElL:LMN 406 6; !%T , r   