
    hU                         S r SSKrSSKrSSKrSSKJr  SSK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 r " S S\5      r " S S\5      rS r SS jrg)zJ
Helper classes to adjust the positions of multiple axes at drawing time.
    N)_api)SubplotSpec   )	axes_sizec                       \ rS rSrSr SS jrS rS rS rS r	S	 r
S
 rS rS rS rS rS rSS jrS rS rS rS r\S 5       r\S 5       rSS jrS rS rSS jrSrg) Divider   a5  
An Axes positioning class.

The divider is initialized with lists of horizontal and vertical sizes
(:mod:`mpl_toolkits.axes_grid1.axes_size`) based on which a given
rectangular area will be divided.

The `new_locator` method then creates a callable object
that can be used as the *axes_locator* of the axes.
Nc                     Xl         X l        X0l        X@l        X`l        U R                  U5        XPl        SU l        SU l        SU l	        g)ak  
Parameters
----------
fig : Figure
pos : tuple of 4 floats
    Position of the rectangle that will be divided.
horizontal : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
    Sizes for horizontal division.
vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
    Sizes for vertical division.
aspect : bool, optional
    Whether overall rectangular area is reduced so that the relative
    part of the horizontal and vertical scales have the same scale.
anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}, default: 'C'
    Placement of the reduced rectangle, when *aspect* is True.
r   N)
_fig_pos_horizontal	_vertical_anchor
set_anchor_aspect
_xrefindex
_yrefindex_locator)selffigpos
horizontalverticalaspectanchors          V/var/www/html/env/lib/python3.13/site-packages/mpl_toolkits/axes_grid1/axes_divider.py__init__Divider.__init__   sD    ( 		%!    c                     [         R                  " U R                  5        Vs/ s H  o"R                  U5      PM     sn5      $ s  snf N)nparrayget_horizontalget_sizer   rendererss      r   get_horizontal_sizesDivider.get_horizontal_sizes;   s5    xxt7J7J7LM7L!H-7LMNNM   Ac                     [         R                  " U R                  5        Vs/ s H  o"R                  U5      PM     sn5      $ s  snf r!   )r"   r#   get_verticalr%   r&   s      r   get_vertical_sizesDivider.get_vertical_sizes>   s5    xxt7H7H7JK7J!H-7JKLLKr+   c                     Xl         g)z
Set the position of the rectangle.

Parameters
----------
pos : tuple of 4 floats
    position of the rectangle that will be divided
Nr   )r   r   s     r   set_positionDivider.set_positionA   s	     	r   c                     U R                   $ )z%Return the position of the rectangle.r1   r   s    r   get_positionDivider.get_positionL   s    yyr   c                     [        U[        5      (       a.  [        R                  " [        R
                  R                  US9  O5[        U[        [        45      (       a  [        U5      S:w  a  [        S5      eXl        g)a?  
Parameters
----------
anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}
    Either an (*x*, *y*) pair of relative coordinates (0 is left or
    bottom, 1 is right or top), 'C' (center), or a cardinal direction
    ('SW', southwest, is bottom left, etc.).

See Also
--------
.Axes.set_anchor
)r      zanchor must be str or 2-tupleN)
isinstancestrr   check_in_listmtransformsBboxcoefstuplelistlen	TypeErrorr   )r   r   s     r   r   Divider.set_anchorP   sZ     fc""{//55fEFUDM22c&kQ6F;<<r   c                     U R                   $ )zReturn the anchor.)r   r5   s    r   
get_anchorDivider.get_anchord       ||r   c                     g r!    r5   s    r   get_subplotspecDivider.get_subplotspech   s    r   c                     Xl         g)zo
Parameters
----------
h : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
    sizes for horizontal division
Nr   )r   hs     r   set_horizontalDivider.set_horizontalk   s
     r   c                     U R                   $ )zReturn horizontal sizes.rN   r5   s    r   r$   Divider.get_horizontalt   s    r   c                     Xl         g)zm
Parameters
----------
v : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
    sizes for vertical division
Nr   )r   vs     r   set_verticalDivider.set_verticalx   s	     r   c                     U R                   $ )zReturn vertical sizes.rU   r5   s    r   r-   Divider.get_vertical   s    ~~r   c                     Xl         g)z%
Parameters
----------
aspect : bool
Nr   r   r   s     r   
set_aspectDivider.set_aspect   s	     r   c                     U R                   $ )zReturn aspect.r\   r5   s    r   
get_aspectDivider.get_aspect   rH   r   c                     Xl         g r!   r   )r   r   s     r   set_locatorDivider.set_locator   s     r   c                     U R                   $ r!   rd   r5   s    r   get_locatorDivider.get_locator   s    }}r   c                 r    U R                   c  U R                  5       $ U R                  X5      R                  $ r!   )r   r6   bounds)r   axr'   s      r   get_position_runtimeDivider.get_position_runtime   s0    == $$&&==.555r   c                 H    U R                  S5      u  p#U(       a  X-
  U-  $ S$ )Nr   )sum)sizestotalrel_sumabs_sums       r   _calc_kDivider._calc_k   s(     !99Q<.57*<1<r   c                 <    [         R                  " S/XS/-  Q5      $ )Nr   r   )r"   cumsum)rq   ks     r   _calc_offsetsDivider._calc_offsets   s!     yy!/u1v~/00r   c                     Uc  US-   nUc  US-   nU R                   nU R                  n[        R                  " U R                  X-
  X&-
  X5-
  XF-
  5      nU R
                  Ul        U$ )a  
Return an axes locator callable for the specified cell.

Parameters
----------
nx, nx1 : int
    Integers specifying the column-position of the
    cell. When *nx1* is None, a single *nx*-th column is
    specified. Otherwise, location of columns spanning between *nx*
    to *nx1* (but excluding *nx1*-th column) is specified.
ny, ny1 : int
    Same as *nx* and *nx1*, but for row positions.
r   )r   r   	functoolspartial_locaterK   )r   nxnynx1ny1xrefyreflocators           r   new_locatorDivider.new_locator   so     ;q&C;q&C ##LL")RY
CJH"&"6"6r   c                 H   XR                   -  nX0R                   -  nX R                  -  nX@R                  -  nU R                  R                  R                  U R                  R
                  -  u  pxU R                  XV5      u  ppU R                  U5      nU R                  U5      nU R                  XU-  5      nU R                  XU-  5      nU R                  5       (       a  [        UU5      nU R                  UU5      nU R                  UU5      nUS   US   -
  U-  nUS   US   -
  U-  n[        R                  R                  XX5      n[        R                  R                  XUU5      nUR!                  U R#                  5       U5      R$                  u  nnO&U R                  X5      nU R                  UU5      nXnnUc  SnUc  SnUUU   U-  -   UU   UU   -
  U-  nnUUU   U-  -   UU   UU   -
  U-  nn[        R                  R                  UUUU5      $ )z
Implementation of ``divider.new_locator().__call__``.

The axes locator callable returned by ``new_locator()`` is created as
a `functools.partial` of this method with *nx*, *ny*, *nx1*, and *ny1*
specifying the requested cell.
r   )r   r   r   bboxsizedpirm   r)   r.   ru   ra   minrz   r=   r>   from_boundsanchoredrF   p0)r   r   r   r   r   axesr'   fig_wfig_hxywrO   hsizesvsizesk_hk_vry   oxoywwhhpbpb1x0y0x1w1y1h1s                                 r   r   Divider._locate   s    	oo
ooyy~~**TYY]]:..t>
a**84((2ll619-ll619-??CA##FA.B##FA.BR&2a5.E)BR&2a5.E)B!!--aA9B""..qR<C\\$//"3R8;;FB ##F0B##FC0BB;C;Cbfun$r#wB'75&@Bbfun$r#wB'75&@B++BB;;r   c                    [         R                  " / SQUS9  US:X  a2  U R                  R                  SU5        U =R                  S-  sl        g US:X  a  U R                  R                  U5        g US:X  a2  U R                  R                  SU5        U =R                  S-  sl        g U R                  R                  U5        g )Nleftrightbottomtoppositionr   r   r   r   r   )r   r<   r   insertr   appendr   r   )r   r   r   s      r   append_sizeDivider.append_size   s    =$,	.v##At,OOq O ##D)!NN!!!T*OOq ONN!!$'r   c                 v    Uc  / SQnU H,  nU R                  U[        R                  " X5      U-   5        M.     g)a  
Add auto-adjustable padding around *use_axes* to take their decorations
(title, labels, ticks, ticklabels) into account during layout.

Parameters
----------
use_axes : `~matplotlib.axes.Axes` or list of `~matplotlib.axes.Axes`
    The Axes whose decorations are taken into account.
pad : float, default: 0.1
    Additional padding in inches.
adjust_dirs : list of {"left", "right", "bottom", "top"}, optional
    The sides where padding is added; defaults to all four sides.
Nr   )r   Size_AxesDecorationsSize)r   use_axespadadjust_dirsds        r   add_auto_adjustable_area Divider.add_auto_adjustable_area  s9     <KAQ 9 9( F LM r   )	r   r   r   r   r   r   r   r   r   )NC)FNN)皙?N)__name__
__module____qualname____firstlineno____doc__r   r)   r.   r2   r6   r   rF   rK   rP   r$   rW   r-   r^   ra   re   rh   rm   staticmethodru   rz   r   r   r   r   __static_attributes__rJ   r   r   r   r      s    	 &)>OM	( !6 = = 1 1
@-<^(Nr   r   c                   L   ^  \ rS rSrSrSSSSS.U 4S jjrS rS rS	 rS
r	U =r
$ )SubplotDivideri  zL
The Divider class whose rectangle area is specified as a subplot geometry.
Nr   r   r   r   r   c          	         > Xl         [        TU ]	  U/ SQU=(       d    / U=(       d    / XES9  U R                  [        R
                  " X5      5        g)a  
Parameters
----------
fig : `~matplotlib.figure.Figure`

*args : tuple (*nrows*, *ncols*, *index*) or int
    The array of subplots in the figure has dimensions ``(nrows,
    ncols)``, and *index* is the index of the subplot being created.
    *index* starts at 1 in the upper left corner and increases to the
    right.

    If *nrows*, *ncols*, and *index* are all single digit numbers, then
    *args* can be passed as a single 3-digit number (e.g. 234 for
    (2, 3, 4)).
horizontal : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional
    Sizes for horizontal division.
vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional
    Sizes for vertical division.
aspect : bool, optional
    Whether overall rectangular area is reduced so that the relative
    part of the horizontal and vertical scales have the same scale.
anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'}, default: 'C'
    Placement of the reduced rectangle, when *aspect* is True.
)r   r   r   r   r   N)figuresuperr   set_subplotspecr   _from_subplot_args)r   r   r   r   r   r   args	__class__s          r   r   SubplotDivider.__init__   sL    6 l$.$4"x~2 & 	 	7 	[;;CFGr   c                 h    U R                  5       R                  U R                  5      R                  $ )z%Return the bounds of the subplot box.)rK   r6   r   rk   r5   s    r   r6   SubplotDivider.get_positionA  s&    ##%224;;?FFFr   c                     U R                   $ )zGet the SubplotSpec instance.)_subplotspecr5   s    r   rK   SubplotDivider.get_subplotspecE  s       r   c                 d    Xl         U R                  UR                  U R                  5      5        g)zSet the SubplotSpec instance.N)r   r2   r6   r   )r   subplotspecs     r   r   SubplotDivider.set_subplotspecI  s%    '+224;;?@r   )r   r   )r   r   r   r   r   r   r6   rK   r   r   __classcell__r   s   @r   r   r     s8     /3TSH HBG!A Ar   r   c                   |   ^  \ rS rSrSrSU 4S jjrSS.S jrSS jrSS jrSSS.S	 jjr	S
 r
S rS rS rSrU =r$ )AxesDivideriO  z(
Divider based on the preexisting axes.
Nc           	        > Xl         Uc  [        R                  " U5      U l        OX l        Uc  [        R                  " U5      U l        OX0l        [        TU ]  UR                  5       SU R                  /U R
                  /SSS9  g)zG
Parameters
----------
axes : :class:`~matplotlib.axes.Axes`
xref
yref
Nr   )r   r   r   r   r   r   )	_axesr   AxesX_xrefAxesY_yrefr   r   
get_figure)r   r   r   r   r   s       r   r   AxesDivider.__init__T  sq     
<D)DJJ<D)DJJT__.D%)ZZLDJJ< $S 	 	2r   )
axes_classc                    U R                   nUc  [        U5      nU" UR                  5       UR                  SS940 UD6$ NT)original)r   typer   r6   )r   r   kwargsr   s       r   _get_new_axesAxesDivider._get_new_axesj  sH    zzdJ$//+T->->->-M $"$ 	$r   c                 `   Uc   [         R                  S   U R                  -  nU(       a  SOSnU(       aN  [        U[        R
                  5      (       d  [        R                  " X R                  S9nU R                  XR5        [        U[        R
                  5      (       d  [        R                  " XR                  S9nU R                  XQ5        U R                  U(       a  SO[        U R                  5      S-
  U R                  S9nU R                  " S0 UD6nUR                  U5        U$ )	z
Helper method for ``append_axes("left")`` and ``append_axes("right")``.

See the documentation of `append_axes` for more details.

:meta private:
zfigure.subplot.wspacer   r   fraction_refr   r   r   r   rJ   )mplrcParamsr   r:   r   _Basefrom_anyr   r   rB   r   r   r   set_axes_locatorr   r   r   
pack_startr   r   r   rl   s           r   new_horizontalAxesDivider.new_horizontalq  s     ;,,67$**DC"fc4::..mmCjjAS&$

++==JJ?D#""qC(8(8$9A$= #   )&)
G$	r   c                 `   Uc   [         R                  S   U R                  -  nU(       a  SOSnU(       aN  [        U[        R
                  5      (       d  [        R                  " X R                  S9nU R                  XR5        [        U[        R
                  5      (       d  [        R                  " XR                  S9nU R                  XQ5        U R                  U R                  U(       a  SO[        U R                  5      S-
  S9nU R                  " S0 UD6nUR                  U5        U$ )	z
Helper method for ``append_axes("top")`` and ``append_axes("bottom")``.

See the documentation of `append_axes` for more details.

:meta private:
zfigure.subplot.hspacer   r   r   r   r   r   rJ   )r   r   r   r:   r   r   r   r   r   r   rB   r   r   r   r   s           r   new_verticalAxesDivider.new_vertical  s     ;,,67$**DC$h%c4::..mmCjjAS&$

++==JJ?D#""qC$7!$; # = )&)
G$	r   c                    [         R                  " U R                  S4U R                  S4U R                  S4U R                  S4S.US9u  pgU" X#4XtS.UD6nU R                  R                  U5        U$ )a  
Add a new axes on a given side of the main axes.

Parameters
----------
position : {"left", "right", "bottom", "top"}
    Where the new axes is positioned relative to the main axes.
size : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
    The axes width or height.  float or str arguments are interpreted
    as ``axes_size.from_any(size, AxesX(<main_axes>))`` for left or
    right axes, and likewise with ``AxesY`` for bottom or top axes.
pad : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
    Padding between the axes.  float or str arguments are interpreted
    as for *size*.  Defaults to :rc:`figure.subplot.wspace` times the
    main Axes width (left or right axes) or :rc:`figure.subplot.hspace`
    times the main Axes height (bottom or top axes).
axes_class : subclass type of `~.axes.Axes`, optional
    The type of the new axes.  Defaults to the type of the main axes.
**kwargs
    All extra keywords arguments are passed to the created axes.
TFr   r   )r   r   )r   check_getitemr   r   r   add_axes)	r   r   r   r   r   r   create_axesr   rl   s	            r   append_axesAxesDivider.append_axes  s    . #'"4"4(($/))51(($/%%u-	6

 # O",OGMO		2	r   c                 x    U R                   c"  U R                  R                  5       nUS:X  a  ggU R                   $ )NautoFT)r   r   ra   r]   s     r   ra   AxesDivider.get_aspect  s6    <<ZZ**,F<<r   c                 ~    U R                   c%  U R                  R                  SS9nUR                  $ U R                   $ r   )r   r   r6   rk   )r   r   s     r   r6   AxesDivider.get_position  s7    99::**D*9D;;99r   c                 h    U R                   c  U R                  R                  5       $ U R                   $ r!   )r   r   rF   r5   s    r   rF   AxesDivider.get_anchor  s)    <<::((**<<r   c                 6    U R                   R                  5       $ r!   )r   rK   r5   s    r   rK   AxesDivider.get_subplotspec  s    zz))++r   )r   r   r   r   )NFr!   )r   r   r   r   r   r   r   r   r   r  ra   r6   rF   rK   r   r   r   s   @r   r   r   O  sG    2, +/ $22 $  D  , ,r   r   c	                    Xb-  n	Xs-  n
[        U5      nUR                  u  pUR                  u  p[        R                  " / UQSP5      nSUS U2S4'   UUSS S24'   / U* QXR	                  5       -
  Pn[        R
                  R                  UU5      Gt nnUU
:  a  X-
  U-  n[        R                  " S/UU-  U-   Q5      nUS   US   -
  U-  nUS   u  nnUS   U-  U-   U-  n[        R                  R                  XX#5      n[        R                  R                  XUU5      nUR                  UU5      R                  u  nnUUUU4$ )Nr   r   )rB   Tr"   diagrp   linalgsolverx   r=   r>   r   r   r   )r   r   r   rO   summed_widthsequal_heightsr   r   r   total_width
max_heightneq_relseq_absssm_relssm_abssABkarrayheightr   r   h0_relh0_absr   r   r   r   r   s                                r   r   r     sm   )KJ 	MA$G$G
'1AAbqb"fIAb#2#gJ2G82kKKM12A
 iiooa+OVV
&'1 
A56)G35	6B
R&2a5.E	!B"1%NFF
)F
V
#u	,B				%	%aA	1B



&
&qR
4C\\&"%((FBr2r>r   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )HBoxDivideri  z
A `.SubplotDivider` for laying out axes horizontally, while ensuring that
they have equal heights.

Examples
--------
.. plot:: gallery/axes_grid1/demo_axes_hbox_divider.py
c                 (   > [         TU ]  USUS5      $ )aI  
Create an axes locator callable for the specified cell.

Parameters
----------
nx, nx1 : int
    Integers specifying the column-position of the
    cell. When *nx1* is None, a single *nx*-th column is
    specified. Otherwise, location of columns spanning between *nx*
    to *nx1* (but excluding *nx1*-th column) is specified.
r   r   r   )r   r   r   r   s      r   r   HBoxDivider.new_locator  s     w"2q#q11r   c                    XR                   -  nX0R                   -  nU R                  R                  R                  U R                  R                  -  u  pxU R                  XV5      u  ppU R                  U5      nU R                  U5      n[        XXXXxU R                  5       5	      u  nnnnUc  SnUUU   U-  -   UU   UU   -
  U-  nnUUnn[        R                  R                  UUUU5      $ Nr   )r   r   r   r   r   rm   r)   r.   r   rF   r=   r>   r   )r   r   r   r   r   r   r'   r   r   r   r   r   rO   	summed_wsequal_hsr   r   r   r   r   r   r   r   s                          r   r   HBoxDivider._locate  s    
ooyy~~**TYY]]:..t>
a--h7	**84 !	U4??;LNBB;Cbfun$r#wB'75&@BRB++BB;;r   rJ   r!   	r   r   r   r   r   r   r   r   r   r   s   @r   r#  r#    s    2< <r   r#  c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )VBoxDivideri-  za
A `.SubplotDivider` for laying out axes vertically, while ensuring that
they have equal widths.
c                 (   > [         TU ]  SUSU5      $ )a=  
Create an axes locator callable for the specified cell.

Parameters
----------
ny, ny1 : int
    Integers specifying the row-position of the
    cell. When *ny1* is None, a single *ny*-th row is
    specified. Otherwise, location of rows spanning between *ny*
    to *ny1* (but excluding *ny1*-th row) is specified.
r   r%  )r   r   r   r   s      r   r   VBoxDivider.new_locator3  s     w"1b!S11r   c                    X R                   -  nX@R                   -  nU R                  R                  R                  U R                  R                  -  u  pxU R                  XV5      u  ppU R                  U5      nU R                  U5      n[        XXXXU R                  5       5	      u  nnnnUc  SnUUnnUUU   U-  -   UU   UU   -
  U-  nn[        R                  R                  UUUU5      $ r(  )r   r   r   r   r   rm   r.   r)   r   rF   r=   r>   r   )r   r   r   r   r   r   r'   r   r   r   r   r   rO   	summed_hsequal_wsr   r   r   r   r   r   r   r   s                          r   r   VBoxDivider._locateA  s    
ooyy~~**TYY]]:..t>
a++H5	,,X6 !	U4??;LNBB;CRBbfun$r#wB'75&@B++BB;;r   rJ   r!   r,  r   s   @r   r.  r.  -  s    
2< <r   r.  c                 ^    [        U 5      nUR                  SSS9nU R                  U5        U$ )Nr   r   )r   r   r   )r   dividerr   s      r   make_axes_locatabler7  R  s4    $G!!Q1!-G'"Nr   c                 R    Uc  / SQn[        U 5      nUc  U nUR                  XUS9  g)a/  
Add auto-adjustable padding around *ax* to take its decorations (title,
labels, ticks, ticklabels) into account during layout, using
`.Divider.add_auto_adjustable_area`.

By default, padding is determined from the decorations of *ax*.
Pass *use_axes* to consider the decorations of other Axes instead.
Nr   )r   r   r   )r7  r   )rl   r   r   r   r6  s        r   make_axes_area_auto_adjustabler9  Z  s<     8!"%G$$h1< % >r   )Nr   N)r   r}   numpyr"   
matplotlibr   r   matplotlib.gridspecr   matplotlib.transforms
transformsr=    r   r   r   r   r   r   r#  r.  r7  r9  rJ   r   r   <module>r@     s}        + + HN HNV1AW 1AhN,' N,hB&<. &<R"<. "<J 15>r   