
    hL                        S r SSKJrJr  SSKJr  SSKJrJr  SSK	J
r
  SSKJr  SSKJrJr  SS	KJr  SS
KJr   " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS r\R6                      SS j5       r\R6                      SS j5       r " S S\5      r\R6                  S 5       rg)zK
A collection of functions and objects for creating or placing inset axes.
    )_api
_docstring)AnchoredOffsetbox)Patch	Rectangle)Path)Bbox)IdentityTransformTransformedBbox   )	axes_size)HostAxesc                   :   ^  \ rS rSr SU 4S jjrS rS rSrU =r$ )AnchoredLocatorBase   c           	      (   > [         TU ]  USS UXS9  g )Ng        )padchild	borderpadbbox_to_anchorbbox_transform)super__init__)selfr   	offsetboxlocr   r   	__class__s         W/var/www/html/env/lib/python3.13/site-packages/mpl_toolkits/axes_grid1/inset_locator.pyr   AnchoredLocatorBase.__init__   s!    Rty) 	 	
    c                     [        S5      e)NzNo draw method should be called)RuntimeError)r   renderers     r   drawAnchoredLocatorBase.draw   s    <==r    c                 l   UR                  SS9nUc  UR                  5       nXl        U R                  U5      nU R	                  UR
                  UR                  SSU5      u  pV[        R                  " XVUR
                  UR                  5      nUR                  R                  5       n[        Xx5      $ )NFrootr   )
get_figure_get_rendereraxesget_window_extent
get_offsetwidthheightr	   from_boundstransSubfigureinvertedr   )	r   axr#   figbboxpxpybbox_canvastrs	            r   __call__AnchoredLocatorBase.__call__   s    mmm'((*H	%%h/T[[!QI&&rtzz4;;G((*{//r    )r+         ?N)	__name__
__module____qualname____firstlineno__r   r$   r:   __static_attributes____classcell__r   s   @r   r   r      s    /3
>	0 	0r    r   c                   4   ^  \ rS rSr SU 4S jjrS rSrU =r$ )AnchoredSizeLocator'   c                    > [         TU ]  US UXVS9  [        R                  " U5      U l        [        R                  " U5      U l        g N)r   r   )r   r   Sizefrom_anyx_sizey_size)r   r   rL   rM   r   r   r   r   s          r   r   AnchoredSizeLocator.__init__(   sA    D# 	 	

 mmF+mmF+r    c                    U R                  5       nUR                  S5      nU R                  R                  U5      u  pEUR                  U-  XS-  -   nU R
                  R                  U5      u  pEUR                  U-  XS-  -   nUR                  U R                  R                  5       5      nU R                  U-  n	[        R                  " SSXg5      R                  U	5      $ )Ng      R@r   )get_bbox_to_anchorpoints_to_pixelsrL   get_sizer.   rM   r/   propget_size_in_pointsr   r	   r0   padded)
r   r#   r5   dpirar.   r/   fontsizer   s
             r   get_bboxAnchoredSizeLocator.get_bbox2   s    &&('',{{##H-

Q({{##H-q17*,,TYY-I-I-KLhh!1e4;;C@@r    )rL   rM   r<   r>   r?   r@   rA   r   rZ   rB   rC   rD   s   @r   rF   rF   '   s    /3,A Ar    rF   c                   8   ^  \ rS rSr   SU 4S jjrS rSrU =r$ )AnchoredZoomLocatorA   c                 \   > Xl         X l        Uc  UR                  n[        TU ]  US X4US9  g rI   )parent_axeszoomr5   r   r   )r   ra   rb   r   r   r   r   r   s          r   r   AnchoredZoomLocator.__init__B   s=     '	!(--ND#) 	 	+r    c           	         U R                   R                  R                  U R                  R                  5      nUR                  U R                  R                  5       5      nU R                  U-  n[        R                  " SS[        UR                  U R                  -  5      [        UR                  U R                  -  5      5      R                  U5      $ Nr   )ra   	transDatatransform_bboxr+   viewLimrQ   rS   rT   r   r	   r0   absr.   rb   r/   rU   )r   r#   bbrY   r   s        r   rZ   AnchoredZoomLocator.get_bboxN   s    ''66tyy7H7HI,,TYY-I-I-KLhh!1c"((TYY./RYY5J1KMVC[	r    )ra   rb   )r=   NNr\   rD   s   @r   r^   r^   A   s     $ $
+ r    r^   c                   L   ^  \ rS rSr\R
                  U 4S j5       rS rSrU =r	$ )	BboxPatchX   c                 n   > SU;   a  [        S5      e[        5       US'   [        TU ]  " S0 UD6  Xl        g)z
Patch showing the shape bounded by a Bbox.

Parameters
----------
bbox : `~matplotlib.transforms.Bbox`
    Bbox to use for the extents of this patch.

**kwargs
    Patch properties. Valid arguments include:

    %(Patch:kwdoc)s
	transformtransform should not be setN )
ValueErrorr
   r   r   r5   )r   r5   kwargsr   s      r   r   BboxPatch.__init__Y   s;     & :;;/1{"6"	r    c                 p    U R                   R                  u  pp4[        R                  " X4X24X44X4/5      $ N)r5   extentsr   _create_closed)r   x0y0x1y1s        r   get_pathBboxPatch.get_patho   s7    **""RHrh2(#KLLr    )r5   
r>   r?   r@   rA   r   interpdr   r~   rB   rC   rD   s   @r   rm   rm   X   s'     *M Mr    rm   c                   t   ^  \ rS rSr\S 5       r\SS j5       r\R                  SU 4S jj5       r	S r
SrU =r$ )BboxConnectoru   c                 j    U R                   u  p#pEUS:X  a  XE4$ US:X  a  X%4$ US:X  a  X#4$ US:X  a  XC4$ g)z
Return the ``(x, y)`` coordinates of corner *loc* of *bbox*; parameters
behave as documented for the `.BboxConnector` constructor.
r            N)rx   )r5   r   rz   r{   r|   r}   s         r   get_bbox_edge_posBboxConnector.get_bbox_edge_posv   sN     !86MAX6MAX6MAX6M r    c                    [        U [        5      (       a-  [        [        R                  " 5       U R                  5       5      n [        U[        5      (       a-  [        [        R                  " 5       UR                  5       5      nUc  Un[        R                  X5      u  pE[        R                  X5      u  pg[        XE/Xg//5      $ )z
Construct a `.Path` connecting corner *loc1* of *bbox1* to corner
*loc2* of *bbox2*, where parameters behave as documented as for the
`.BboxConnector` constructor.
)	
isinstancer   r   r	   unitget_transformr   r   r   )bbox1bbox2loc1loc2r|   r}   x2y2s           r   connect_bboxBboxConnector.connect_bbox   s     eY''#DIIK1D1D1FGEeY''#DIIK1D1D1FGE<D00=00=bXx())r    c                    > SU;   a  [        S5      e[        5       US'   UR                  S[        1 SkR	                  U5      5      5        [
        TU ]  " S0 UD6  Xl        X l        X0l	        X@l
        g)a  
Connect two bboxes with a straight line.

Parameters
----------
bbox1, bbox2 : `~matplotlib.transforms.Bbox`
    Bounding boxes to connect.

loc1, loc2 : {1, 2, 3, 4}
    Corner of *bbox1* and *bbox2* to draw the line. Valid values are::

        'upper right'  : 1,
        'upper left'   : 2,
        'lower left'   : 3,
        'lower right'  : 4

    *loc2* is optional and defaults to *loc1*.

**kwargs
    Patch properties for the line drawn. Valid arguments include:

    %(Patch:kwdoc)s
rp   rq   fill>   fccolor	facecolorNrr   )rs   r
   
setdefaultboolintersectionr   r   r   r   r   r   )r   r   r   r   r   rt   r   s         r   r   BboxConnector.__init__   so    2 & :;;/1{D5BB6JK	M"6"

		r    c                 z    U R                  U R                  U R                  U R                  U R                  5      $ rw   )r   r   r   r   r   )r   s    r   r~   BboxConnector.get_path   s.      TZZ!%DII7 	7r    )r   r   r   r   rw   )r>   r?   r@   rA   staticmethodr   r   r   r   r   r~   rB   rC   rD   s   @r   r   r   u   sN      * *  " "H7 7r    r   c                   L   ^  \ rS rSr\R
                  U 4S j5       rS rSrU =r	$ )BboxConnectorPatch   c                 d   > SU;   a  [        S5      e[        TU ]  " XX440 UD6  XPl        X`l        g)a:  
Connect two bboxes with a quadrilateral.

The quadrilateral is specified by two lines that start and end at
corners of the bboxes. The four sides of the quadrilateral are defined
by the two lines given, the line between the two corners specified in
*bbox1* and the line between the two corners specified in *bbox2*.

Parameters
----------
bbox1, bbox2 : `~matplotlib.transforms.Bbox`
    Bounding boxes to connect.

loc1a, loc2a, loc1b, loc2b : {1, 2, 3, 4}
    The first line connects corners *loc1a* of *bbox1* and *loc2a* of
    *bbox2*; the second line connects corners *loc1b* of *bbox1* and
    *loc2b* of *bbox2*.  Valid values are::

        'upper right'  : 1,
        'upper left'   : 2,
        'lower left'   : 3,
        'lower right'  : 4

**kwargs
    Patch properties for the line drawn:

    %(Patch:kwdoc)s
rp   rq   N)rs   r   r   loc1bloc2b)	r   r   r   loc1aloc2ar   r   rt   r   s	           r   r   BboxConnectorPatch.__init__   s7    < & :;;u>v>

r    c                 Z   U R                  U R                  U R                  U R                  U R                  5      nU R                  U R                  U R                  U R
                  U R                  5      n/ UR                  QUR                  QUR                  S   Pn[        U5      $ re   )	r   r   r   r   r   r   r   verticesr   )r   path1path2path_mergeds       r   r~   BboxConnectorPatch.get_path   s    !!$**djj$))TYYO!!$**djj"&**djj:KKK9JKK  r    )r   r   r   rD   s   @r   r   r      s&    ! !F! !r    r   c                     Uc  [         nUc  0 nU R                  SS9nU" X@R                  5       40 SS0UESU0ED6nUR                  U5      $ )zBHelper function to add an inset axes and disable navigation in it.Fr'   navigateaxes_locator)r   r)   get_positionadd_axes)ra   
axes_classaxes_kwargsr   r4   
inset_axess         r   _add_inset_axesr      sm    


 
 e
 
,C%%'Lu
J
J^\
JLJ <<
##r    Nc	                    XPR                   U R                  SS9R                  4;   a  Uc  [        R                  " S5        SnUc  U R
                  n[        U[        5      (       aD  [        U[        5      (       d  [        U[        5      (       a  [        U5      S:w  a  [        S5      e[        XU[        XAX#XXS95      $ )a,  
Create an inset axes with a given width and height.

Both sizes used can be specified either in inches or percentage.
For example,::

    inset_axes(parent_axes, width='40%%', height='30%%', loc='lower left')

creates in inset axes in the lower left corner of *parent_axes* which spans
over 30%% in height and 40%% in width of the *parent_axes*. Since the usage
of `.inset_axes` may become slightly tricky when exceeding such standard
cases, it is recommended to read :doc:`the examples
</gallery/axes_grid1/inset_locator_demo>`.

Notes
-----
The meaning of *bbox_to_anchor* and *bbox_to_transform* is interpreted
differently from that of legend. The value of bbox_to_anchor
(or the return value of its get_points method; the default is
*parent_axes.bbox*) is transformed by the bbox_transform (the default
is Identity transform) and then interpreted as points in the pixel
coordinate (which is dpi dependent).

Thus, following three calls are identical and creates an inset axes
with respect to the *parent_axes*::

   axins = inset_axes(parent_axes, "30%%", "40%%")
   axins = inset_axes(parent_axes, "30%%", "40%%",
                      bbox_to_anchor=parent_axes.bbox)
   axins = inset_axes(parent_axes, "30%%", "40%%",
                      bbox_to_anchor=(0, 0, 1, 1),
                      bbox_transform=parent_axes.transAxes)

Parameters
----------
parent_axes : `matplotlib.axes.Axes`
    Axes to place the inset axes.

width, height : float or str
    Size of the inset axes to create. If a float is provided, it is
    the size in inches, e.g. *width=1.3*. If a string is provided, it is
    the size in relative units, e.g. *width='40%%'*. By default, i.e. if
    neither *bbox_to_anchor* nor *bbox_transform* are specified, those
    are relative to the parent_axes. Otherwise, they are to be understood
    relative to the bounding box provided via *bbox_to_anchor*.

loc : str, default: 'upper right'
    Location to place the inset axes.  Valid locations are
    'upper left', 'upper center', 'upper right',
    'center left', 'center', 'center right',
    'lower left', 'lower center', 'lower right'.
    For backward compatibility, numeric values are accepted as well.
    See the parameter *loc* of `.Legend` for details.

bbox_to_anchor : tuple or `~matplotlib.transforms.BboxBase`, optional
    Bbox that the inset axes will be anchored to. If None,
    a tuple of (0, 0, 1, 1) is used if *bbox_transform* is set
    to *parent_axes.transAxes* or *parent_axes.figure.transFigure*.
    Otherwise, *parent_axes.bbox* is used. If a tuple, can be either
    [left, bottom, width, height], or [left, bottom].
    If the kwargs *width* and/or *height* are specified in relative units,
    the 2-tuple [left, bottom] cannot be used. Note that,
    unless *bbox_transform* is set, the units of the bounding box
    are interpreted in the pixel coordinate. When using *bbox_to_anchor*
    with tuple, it almost always makes sense to also specify
    a *bbox_transform*. This might often be the axes transform
    *parent_axes.transAxes*.

bbox_transform : `~matplotlib.transforms.Transform`, optional
    Transformation for the bbox that contains the inset axes.
    If None, a `.transforms.IdentityTransform` is used. The value
    of *bbox_to_anchor* (or the return value of its get_points method)
    is transformed by the *bbox_transform* and then interpreted
    as points in the pixel coordinate (which is dpi dependent).
    You may provide *bbox_to_anchor* in some normalized coordinate,
    and give an appropriate transform (e.g., *parent_axes.transAxes*).

axes_class : `~matplotlib.axes.Axes` type, default: `.HostAxes`
    The type of the newly created inset axes.

axes_kwargs : dict, optional
    Keyword arguments to pass to the constructor of the inset axes.
    Valid arguments include:

    %(Axes:kwdoc)s

borderpad : float, default: 0.5
    Padding between inset axes and the bbox_to_anchor.
    The units are axes font size, i.e. for a default font size of 10 points
    *borderpad = 0.5* is equivalent to a padding of 5 points.

Returns
-------
inset_axes : *axes_class*
    Inset axes object created.
Fr'   zUsing the axes or figure transform requires a bounding box in the respective coordinates. Using bbox_to_anchor=(0, 0, 1, 1) now.)r   r   r   r   r   zoUsing relative units for width or height requires to provide a 4-tuple or a `Bbox` instance to `bbox_to_anchor.)r   r   r   )	transAxesr)   transFigurer   warn_externalr5   r   tuplestrlenrs   r   rF   )	ra   r.   r/   r   r   r   r   r   r   s	            r   r   r      s    L 	00&11u1=IIK 	K& D 	E &$))>5))s##z&#'>'>~!# C D D 6)	@A Ar    c                 0    [        XU[        XUX4US95      $ )a6
  
Create an anchored inset axes by scaling a parent axes. For usage, also see
:doc:`the examples </gallery/axes_grid1/inset_locator_demo2>`.

Parameters
----------
parent_axes : `~matplotlib.axes.Axes`
    Axes to place the inset axes.

zoom : float
    Scaling factor of the data axes. *zoom* > 1 will enlarge the
    coordinates (i.e., "zoomed in"), while *zoom* < 1 will shrink the
    coordinates (i.e., "zoomed out").

loc : str, default: 'upper right'
    Location to place the inset axes.  Valid locations are
    'upper left', 'upper center', 'upper right',
    'center left', 'center', 'center right',
    'lower left', 'lower center', 'lower right'.
    For backward compatibility, numeric values are accepted as well.
    See the parameter *loc* of `.Legend` for details.

bbox_to_anchor : tuple or `~matplotlib.transforms.BboxBase`, optional
    Bbox that the inset axes will be anchored to. If None,
    *parent_axes.bbox* is used. If a tuple, can be either
    [left, bottom, width, height], or [left, bottom].
    If the kwargs *width* and/or *height* are specified in relative units,
    the 2-tuple [left, bottom] cannot be used. Note that
    the units of the bounding box are determined through the transform
    in use. When using *bbox_to_anchor* it almost always makes sense to
    also specify a *bbox_transform*. This might often be the axes transform
    *parent_axes.transAxes*.

bbox_transform : `~matplotlib.transforms.Transform`, optional
    Transformation for the bbox that contains the inset axes.
    If None, a `.transforms.IdentityTransform` is used (i.e. pixel
    coordinates). This is useful when not providing any argument to
    *bbox_to_anchor*. When using *bbox_to_anchor* it almost always makes
    sense to also specify a *bbox_transform*. This might often be the
    axes transform *parent_axes.transAxes*. Inversely, when specifying
    the axes- or figure-transform here, be aware that not specifying
    *bbox_to_anchor* will use *parent_axes.bbox*, the units of which are
    in display (pixel) coordinates.

axes_class : `~matplotlib.axes.Axes` type, default: `.HostAxes`
    The type of the newly created inset axes.

axes_kwargs : dict, optional
    Keyword arguments to pass to the constructor of the inset axes.
    Valid arguments include:

    %(Axes:kwdoc)s

borderpad : float, default: 0.5
    Padding between inset axes and the bbox_to_anchor.
    The units are axes font size, i.e. for a default font size of 10 points
    *borderpad = 0.5* is equivalent to a padding of 5 points.

Returns
-------
inset_axes : *axes_class*
    Inset axes object created.
)rb   r   r   r   r   )r   r^   )ra   rb   r   r   r   r   r   r   s           r   zoomed_inset_axesr   y  s*    J )	!" "r    c                   8   ^  \ rS rSrSrU 4S jrU 4S jrSrU =r$ )_TransformedBboxWithCallbacki  z
Variant of `.TransformBbox` which calls *callback* before returning points.

Used by `.mark_inset` to unstale the parent axes' viewlim as needed.
c                2   > [         TU ]  " U0 UD6  Xl        g rw   )r   r   	_callback)r   callbackargsrt   r   s       r   r   %_TransformedBboxWithCallback.__init__  s    $)&)!r    c                 @   > U R                  5         [        TU ]	  5       $ rw   )r   r   
get_points)r   r   s    r   r   '_TransformedBboxWithCallback.get_points  s    w!##r    )r   )	r>   r?   r@   rA   __doc__r   r   rB   rC   rD   s   @r   r   r     s    "$ $r    r   c                    [        UR                  U R                  U R                  S9nUR	                  S[        1 SkR                  U5      5      5        [        U40 UD6nU R                  U5        [        UR                  U4SU0UD6nUR                  U5        UR                  S5        [        UR                  U4SU0UD6nUR                  U5        UR                  S5        XgU4$ )aM  
Draw a box to mark the location of an area represented by an inset axes.

This function draws a box in *parent_axes* at the bounding box of
*inset_axes*, and shows a connection with the inset axes by drawing lines
at the corners, giving a "zoomed in" effect.

Parameters
----------
parent_axes : `~matplotlib.axes.Axes`
    Axes which contains the area of the inset axes.

inset_axes : `~matplotlib.axes.Axes`
    The inset axes.

loc1, loc2 : {1, 2, 3, 4}
    Corners to use for connecting the inset axes and the area in the
    parent axes.

**kwargs
    Patch properties for the lines and box drawn:

    %(Patch:kwdoc)s

Returns
-------
pp : `~matplotlib.patches.Patch`
    The patch drawn to represent the area of the inset axes.

p1, p2 : `~matplotlib.patches.Patch`
    The patches connecting two corners of the inset axes and its area.
)r   r   >   r   r   r   r   F)r   rh   rf   _unstale_viewLimr   r   r   rm   	add_patchr   r5   set_clip_on)	ra   r   r   r   rt   rectppp1p2s	            r   
mark_insetr     s    D (K11--/D fd#?#L#LV#TUV	4	"6	"B"	z	B4	B6	BBNN5	z	B4	B6	BBNN52:r    )zupper rightNNNNr=   ) r   
matplotlibr   r   matplotlib.offsetboxr   matplotlib.patchesr   r   matplotlib.pathr   matplotlib.transformsr	   r
   r    r   rJ   parasite_axesr   r   rF   r^   rm   r   r   r   r   r   r   r   r   rr   r    r   <module>r      s    ( 2 /   & D  #0+ 0.A- A4- .M M:J7E J7Z+! +!\
$ /<37,0xA xAv -::>37 #I" I"X$? $  0 0r    