o
    tBh91                     @   sF  d dl Z 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 d dl
mZ ddlmZ G dd dZeed	ZeeZejd
ddG dd dZejd
dde ddd Ze  eeZW d   n1 srw   Y  G dd dZeeddZeeZeeZdd Z eddddZ!eddddZ"dS )    N)_apicbook)subplot_class_factory)Bbox   )Axesc                       s   e Zd Zddd fddZ fddZeddd	 Z fd
dZ fddZ	dd Z
dd Zejddddd Zdd Zd fdd	Z  ZS )ParasiteAxesBaseNviewlim_modec                   s<   || _ || _| | d|d< t j|j|jfi | d S )NFframeon)_parent_axestransAuxset_viewlim_modesuper__init__figure	_positionselfparent_axesaux_transformr
   kwargs	__class__ |/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/parasite_axes.pyr      s
   
zParasiteAxesBase.__init__c                    s*   t    tj|  dd | jj| _d S )NF)visible)r   clamartistsetpget_childrenr   
_get_linesr   r   r   r   r      s   
zParasiteAxesBase.claz3.5c                 C   sJ   g }g }|   D ]}| sqt|tjr|| q|| q||fS N)r    get_visible
isinstancemimage	AxesImageappend)r   artistsimagesar   r   r   get_images_artists   s   z#ParasiteAxesBase.get_images_artistsc                    s@   t  | |  D ]}t|jdr| |jjv r|| q
d S )N	parasites)r   pickr    hasattrinaxesr-   r   
mouseeventr+   r   r   r   r.   *   s   
zParasiteAxesBase.pickc                    sZ   | j d ur&| jj| _| j | jj | _t| j| j| _t| j| j| _d S t 	  d S r#   )
r   r   	transAxes	transDatamtransformsblended_transform_factory_xaxis_transform_yaxis_transformr   _set_lim_and_transformsr"   r   r   r   r9   8   s   


z(ParasiteAxesBase._set_lim_and_transformsc                 C      t jg d|d || _d S NNequal	transformmoder   check_in_list_viewlim_moder   r@   r   r   r   r   C      
z!ParasiteAxesBase.set_viewlim_modec                 C      | j S r#   rC   r"   r   r   r   get_viewlim_modeG      z!ParasiteAxesBase.get_viewlim_mode3.4apply_aspectalternativec                 C   rF   r#   _update_viewlimr"   r   r   r   update_viewlimJ   s   zParasiteAxesBase.update_viewlimc                 C   v   | j j }|  }|d u rd S |dkr| jj| d S |dkr0| jj|| j  d S t	j
g d|d d S Nr=   r>   r<   r?   r   viewLimfrozenrH   axessettransformedr   invertedr   rB   r   viewlimr@   r   r   r   rO   N      z ParasiteAxesBase._update_viewlimc                       |    t   d S r#   rO   r   rK   r   positionr   r   r   rK   [      zParasiteAxesBase.apply_aspectr#   )__name__
__module____qualname__r   r   r   
deprecatedr,   r.   r9   r   rH   rP   rO   rK   __classcell__r   r   r   r   r      s    

r   z
{}ParasiterJ   rL   c                       sb   e Zd Zd fdd	Zdd Zdd Zdd	 Zejd
dddd Z	dd Z
d fdd	Z  ZS )ParasiteAxesAuxTransBaseNc                    s   t  j||fd|i| d S )Nr
   )r   r   r   r   r   r   r   i   s
   
z!ParasiteAxesAuxTransBase.__init__c                 C   sB   | j j| _| j| j j | _t| j| j| _t| j| j| _d S r#   )r   r3   r   r4   r5   r6   r7   r8   r"   r   r   r   r9   o   s   

z0ParasiteAxesAuxTransBase._set_lim_and_transformsc                 C   r:   r;   rA   rD   r   r   r   r   w   rE   z)ParasiteAxesAuxTransBase.set_viewlim_modec                 C   rF   r#   rG   r"   r   r   r   rH   {   rI   z)ParasiteAxesAuxTransBase.get_viewlim_moderJ   rK   rL   c                 C   s   |   S r#   rN   r"   r   r   r   rP   ~   s   z'ParasiteAxesAuxTransBase.update_viewlimc                 C   rQ   rR   rS   rZ   r   r   r   rO      r\   z(ParasiteAxesAuxTransBase._update_viewlimc                    r]   r#   r^   r_   r   r   r   rK      ra   z%ParasiteAxesAuxTransBase.apply_aspectr#   )rb   rc   rd   r   r9   r   rH   r   re   rP   rO   rK   rf   r   r   r   r   rg   g   s    
rg   parasite_axes_class_factoryc                 C   s2   t | ts
t| }n| }td|j t|fddiS )Nz%sParasiteAuxTransnameparasite_axes)
issubclassr   rh   typerb   rg   )
axes_classparasite_axes_classr   r   r   $parasite_axes_auxtrans_class_factory   s   


ro   c                       s   e Zd Z fddZddefddZd fdd	Z fd	d
Z fddZ fddZ	dddZ
dddZdddZdd Zdd Z		d fdd	Z  ZS )HostAxesBasec                    s   g | _ t j|i | d S r#   )r-   r   r   )r   argsr   r   r   r   r      s   zHostAxesBase.__init__Nr=   c                 C   s0   t |}|| ||d}| j| | jj|_|S )a  
        Add a parasite axes to this host.

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

        *tr* may be `.Transform`, in which case the following relation will
        hold: ``parasite.transData = tr + host.transData``.  Alternatively, it
        may be None (the default), no special relationship will hold between
        the parasite's and the host's ``transData``.
        r	   )rh   r-   r(   remove_remove_method)r   trr
   rm   rn   ax2r   r   r   get_aux_axes   s
   
zHostAxesBase.get_aux_axesc                    s*   t   }| jD ]
}||| q|S r#   )r   _get_legend_handlesr-   extend)r   legend_handler_mapall_handlesaxr   r   r   rw      s   

z HostAxesBase._get_legend_handlesc                    s   t | j}|  }|r|| |}| j|dd | | n|   |  }| jD ]}|| | j|  q(t	 
| | jd | | _d S )Nactive)which)len	_childrenget_axes_locatorset_positionrK   get_positionr-   rx   r    r   draw)r   rendererorig_children_lenlocatorposrectr{   r   r   r   r      s   



zHostAxesBase.drawc                    s"   | j D ]}|  qt   d S r#   )r-   r   r   )r   r{   r   r   r   r      s   

zHostAxesBase.clac                    s&   t  | | jD ]}|| q	d S r#   )r   r.   r-   r1   r   r   r   r.      s   
zHostAxesBase.pickc                 C   B   | j || d}| 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   rm   r{   r   r   r   twinx   
   zHostAxesBase.twinxc                 C   r   )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.
        )shareyr   FT)r   r   r   r   r   r   r   r   twiny   r   zHostAxesBase.twinyc                 C   sT   |du rt  }| j||d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
   )r   r   FT)r   r   )r5   IdentityTransformr   r   r   )r   	aux_transrm   r{   r   r   r   twin   s   zHostAxesBase.twinc                 K   s:   |du r| j }t|| fi |}| j| | j|_|S )zy
        Helper for `.twinx`/`.twiny`/`.twin`.

        *kwargs* are forwarded to the parasite axes constructor.
        N)_base_axes_classrh   r-   r(   _remove_any_twinrs   )r   rm   r   r{   r   r   r   r     s   zHostAxesBase._add_twin_axesc                 C   sd   | j | ddg}|jr|d |jr|d | jt| d | jt| jddd d S )Nr   r   TF)
ticklabelslabel)r-   rr   _sharex_shareyr   tupler   toggle)r   r{   restorer   r   r   r     s   

zHostAxesBase._remove_any_twinTc                    s@   g  fdd| j D t j |d}tdd |D S )Nc                    s   g | ]	}|j  d qS ))call_axes_locator)get_tightbbox).0r{   r   r   r   r   
<listcomp>'  s    z.HostAxesBase.get_tightbbox.<locals>.<listcomp>)r   bbox_extra_artistsc                 S   s$   g | ]}|j d ks|jd kr|qS )r   )widthheight)r   br   r   r   r   ,  s   $ )r-   r   r   r   union)r   r   r   r   bbsr   r   r   r   $  s   zHostAxesBase.get_tightbboxr#   )NN)TN)rb   rc   rd   r   r   rv   rw   r   r   r.   r   r   r   r   r   r   rf   r   r   r   r   rp      s    



rp   z
{}HostAxesr   c                 C   s   t | }t|}|S r#   )host_axes_class_factoryr   )rm   host_axes_classsubplot_host_classr   r   r   host_subplot_class_factory5  s   r   )rm   r   c                 O   P   ddl m} t| }|du r| }||g|R i |}|| |  |S )aJ  
    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`` object creation.
    r   N)matplotlib.pyplotpyplotr   gcfadd_axesdraw_if_interactive)rm   r   rq   r   pltr   r{   r   r   r   	host_axes;     
r   c                 O   r   )aQ  
    Create a subplot that can act as a host to parasitic axes.

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

    *args, **kwargs
        Will be passed on to the underlying ``Axes`` object creation.
    r   N)r   r   r   r   add_subplotr   )rm   r   rq   r   r   host_subplot_classr{   r   r   r   host_subplotR  r   r   )#	functools
matplotlibr   r   matplotlib.artistartistr   matplotlib.imageimager&   matplotlib.transforms
transformsr5   matplotlib.axesr   r   mpl_axesr   r   _make_class_factoryrh   ParasiteAxesre   rg   	lru_cachero   'suppress_matplotlib_deprecation_warningParasiteAxesAuxTransrp   r   HostAxesSubplotHostr   r   r   r   r   r   r   <module>   s>    V,

 