
    ^j%                         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                   \     e Zd Zddd fdZ fdZ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        p/var/www/ramen.bs-engineer-server.com/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                 6    | j                   j                         S N)r   get_axes_locatorr   s    r   r+   z!ParasiteAxesBase.get_axes_locator   s      1133r   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   s[     	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 r*   )
r   r   	transAxes	transDatamtransformsblended_transform_factory_xaxis_transform_yaxis_transformr   _set_lim_and_transformsr(   s    r   r<   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   rB   s     r   r   z!ParasiteAxesBase.set_viewlim_mode8   s    7dC!r   c                     | j                   S r*   )rD   r,   s    r   get_viewlim_modez!ParasiteAxesBase.get_viewlim_mode<   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>   rA   )	viewLimfrozenrF   settransformedr   invertedr   rC   )r   parentviewlimrB   s       r   r'   zParasiteAxesBase._sync_lims?   s    ..'')$$&<W_LLW%[ LLW001G1G1IJK;$Gr   r*   )__name__
__module____qualname__r   r    r+   r/   r<   r   rF   r'   __classcell__r   s   @r   r	   r	      s4    :!%:-4
#	.""
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 r*   )r.   r   r   )r   argsr   r   s      r   r   zHostAxesBase.__init__T   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_axesX   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	_childrenr+   set_positionapply_aspectget_positionr.   extendr#   r   draw)r   rendererorig_children_lenlocatorposrectaxr   s          r   rl   zHostAxesBase.draw~   s    /'')$)Cc2c"  ".. 	5BOOD!NN!!"//"34	5 	XNN,-.r   c                 d    t         |           | j                  D ]  }|j                           y r*   )r   r    r.   )r   rr   r   s     r   r    zHostAxesBase.clear   s(    .. 	BHHJ	r   c                 h    t         |   |       | j                  D ]  }|j                  |        y r*   )r   r/   r.   r2   s      r   r/   zHostAxesBase.pick   s0    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_   rr   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.
        )shareyry   FT)rx   rw   rz   r{   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
   )ry   rw   FT)rx   rz   )r8   IdentityTransformr|   r}   r~   )r   	aux_transr_   rr   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.
        )rY   rZ   r.   r[   _remove_any_twinr]   )r   r_   r   rr   s       r   r|   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 )Nry   rw   TF)
ticklabelslabel)r.   r\   _sharex_shareyr}   tupler~   toggle)r   rr   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   rm   r   r   rr   bbsbr   s          r   r   zHostAxesBase.get_tightbbox   s    J( x;LM (J G!(4E5G " IJ zzcKQWW\QXX]1KLL(
 Ls   B#B8B)Nr?   Nr*   )NN)rO   rP   rQ   r   rb   rl   r    r/   r   r   r   r|   r   r   rR   rS   s   @r   rU   rU   S   sT    *
 =A$L/&
 HM)-M Mr   rU   z
{}HostAxesrY   )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   rW   r   plthost_axes_classrr   s          r   	host_axesr      sF     $-j9O~		1$	1&	1B
OOBIr   )
matplotlibr   r   matplotlib.artistartistr!   matplotlib.transforms
transformsr8   r   mpl_axesr   r	   _make_class_factoryrZ   ParasiteAxesrU   r   host_subplot_class_factoryHostAxesSubplotHostr   host_subplot r   r   <module>r      s    " # + & AH AHL 8e77l$ *40SM SMn ElL:LMN 406 6; !%T , r   