
    P/Ph$                        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dS )    )_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                    || _         || _        |                     |           d|d<    t                      j        |                    d          |j        fi | d S )NFframeon)root)_parent_axestransAuxset_viewlim_modesuper__init__
get_figure	_position)selfparent_axesaux_transformr
   kwargs	__class__s        e/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mpl_toolkits/axes_grid1/parasite_axes.pyr   zParasiteAxesBase.__init__
   s{    '%l+++!y//U/;;$.	: 	:28	: 	: 	: 	: 	:    c                 N   t                                                       t          j        |                                 d           | j        j        | _        | j        j                            d| j	                   | j        j                            d| j	                   d S )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888+6#66DO	- 	- 	-#66DO	- 	- 	- 	- 	-r   c                     t                                          |           |                                 D ]:}t          |j        d          r#| |j        j        v r|                    |           ;d S )N	parasites)r   pickr#   hasattrinaxesr*   r   
mouseeventar   s      r   r+   zParasiteAxesBase.pick   s{     	Z    ""$$ 	# 	#A
);77 #
 1 ;;;z"""	# 	#r   c                 >   | j         t| j        j        | _        | j         | j        j        z   | _        t	          j        | j        | j                  | _        t	          j        | j        | j                  | _        d S t                      	                                 d S 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    =$!.8DN!]T->-HHDN$/$I%0 %0D!$/$I%0 %0D!!! GG++-----r   c                 D    t          j        g d|           || _        d S )NNequal	transformmode)r   check_in_list_viewlim_mode)r   r?   s     r   r   z!ParasiteAxesBase.set_viewlim_mode5   s-    777dCCCC!r   c                     | j         S r2   )rA   )r   s    r   get_viewlim_modez!ParasiteAxesBase.get_viewlim_mode9   s    !!r   c                 t   |j                                         }|                                 }|d S |dk    r| j                             |           d S |dk    rF| j                             |                    | j                                                             d S t          j        g d|           d S )Nr<   r=   r;   r>   )	viewLimfrozenrC   settransformedr   invertedr   r@   )r   parentviewlimr?   s       r   r'   zParasiteAxesBase._sync_lims<   s    .''))$$&&<DW__LW%%%%%[  LW001G1G1I1IJJKKKKK;;;$GGGGGGr   r2   )__name__
__module____qualname__r   r    r+   r9   r   rC   r'   __classcell__r   s   @r   r	   r	      s        :!%: : : : : : :- - - - -
# 
# 
# 
# 
#	. 	. 	. 	. 	." " "" " "
H 
H 
H 
H 
H 
H 
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                 H    g | _          t                      j        |i | d S r2   )r*   r   r   )r   argsr   r   s      r   r   zHostAxesBase.__init__Q   s,    $)&)))))r   Nr<   c                     || j         }t          |          } || |fd|i|}| 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.
        Nr
   )_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   sv    6 .J9*EE!!"; ;#/;39; ; 	c"""!^2
r   c                 
   t          | j                  }|                                 }|r9 || |          }|                     |d           |                     |           n|                                  |                                 }| j        D ]C}|                    |           | j                            |                                           Dt                      
                    |           | j        |d = d S )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22c""""  "". 	5 	5BOOD!!!N!!"//"3"34444XN,--...r   c                     t                                                       | j        D ]}|                                 d S r2   )r   r    r*   )r   rp   r   s     r   r    zHostAxesBase.clear   s>    . 	 	BHHJJJJ	 	r   c                     t                                          |           | j        D ]}|                    |           d S r2   )r   r+   r*   r.   s      r   r+   zHostAxesBase.pick   sK    Z     	 	AFF:	 	r   c                     |                      ||           }| j        d                             d           |j        d                             d           |j        d                             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   ss       D 99	'&&u---
$$T***
'(44U;;;	r   c                     |                      ||           }| j        d                             d           |j        d                             d           |j        d                             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   sr       D 99	%$$U+++
""4(((
)*66u===	r   c                     |t          j                    }|                     ||d          }| j        d                             d           |j        d                             d           |j        d                             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.
        Nr=   )r   r
   )rw   ru   FT)rv   rx   )r5   IdentityTransformrz   r{   r|   )r   	aux_transr\   rp   s       r   twinzHostAxesBase.twin   s     #577I  ik ! K K	.!--e444
++D111
 !--e444	r   c                     || j         } t          |          | fi |}| 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   sX     .J4(44TDDVDDb!!! 1	r   c                 j   | j                             |           ddg}|j        r|                    d           |j        r|                    d           | j        t          |                                       d           | j        t          |                                       dd           d S )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33	%..!((E(GGGGGr   Tcall_axes_locatorbbox_extra_artistsc                    g fd| j         D             t                                          |          }t          j        d |D                       S )Nc                 >    g | ]}|                                S ))r   )get_tightbbox).0rp   r   rk   s     r   
<listcomp>z.HostAxesBase.get_tightbbox.<locals>.<listcomp>   s=     ( ( ( x;LMM ( ( (r   r   c                 >    g | ]}|j         d k    s|j        d k    |S )r   )widthheight)r   bs     r   r   z.HostAxesBase.get_tightbbox.<locals>.<listcomp>   s)    KKKQW\\QX]]1]]]r   )r*   r   r   r   union)r   rk   r   r   bbsr   s    ``  r   r   zHostAxesBase.get_tightbbox   s    J( ( ( ( (( ( (J GG!!(4E5G " I IJ zKKcKKKLLLr   )Nr<   Nr2   )NN)rL   rM   rN   r   r_   rj   r    r+   r~   r   r   rz   r   r   rO   rP   s   @r   rR   rR   P   s4       * * * * *
 =A$ $ $ $L/ / / / /&    
                H H HM)-M M M M M M M M M M Mr   rR   z
{}HostAxesrV   )r\   figurec                     ddl m} t          |           }||                                } ||g|R i |}|                    |           |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      sk     $#####-j99O~		1$	1	1	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 >H >H >H >H >H >HF 8e7l$ $ **400SM SM SM SM SM SM SM SMn ElL:LMMN 40066 6; !%T     , r   