
    hT                         S r SSKrSSKrSSKrSSKrSSKrSSK	J
r  SSKJr  \R                  " \5      r " S S5      r\R$                  " 5       rS rSS jrg)	a  
A layoutgrid is a nrows by ncols set of boxes, meant to be used by
`._constrained_layout`, each box is analogous to a subplotspec element of
a gridspec.

Each box is defined by left[ncols], right[ncols], bottom[nrows] and top[nrows],
and by two editable margins for each side.  The main margin gets its value
set by the size of ticklabels, titles, etc on each Axes that is in the figure.
The outer margin is the padding around the Axes, and space for any
colorbars.

The "inner" widths and heights of these boxes are then constrained to be the
same (relative the values of `width_ratios[ncols]` and `height_ratios[nrows]`).

The layoutgrid is then constrained to be contained within a parent layoutgrid,
its column(s) and row(s) specified when it is created.
    N)Bboxc                       \ rS rSrSr    SS jrS rS rS rS	 r	SS
 jr
S rS rS rSS jrS rS rS rS rSS jrSS jrSS jrSS jrSS jrSS jrSS jrS rSrg)
LayoutGrid   z?
Analogous to a gridspec, and contained in another LayoutGrid.
Nr   r   c                    [         R                  nX l        X0l        U[	        5       -   U l        [        U[        5      (       a   UR
                   SU R
                   3U l        X`l        XPl	        [        R                  " U
5      U l        U
c  [        R                  " U5      U l        [        R                  " U	5      U l        U	c  [        R                  " U5      U l        U R
                  S-   n[        U[        5      (       d  [         R                  " 5       U l        O$UR"                  " U /UQ76   UR                   U l        [        R$                  " Xe4[&        S9U l        [        R$                  " Xe4[&        S9U l        0 U l        0 U l        S H&  n[        R0                  " U5      U R.                  U'   M(     U R                   n[3        U5       Vs/ s H  o" U SU S35      PM     snU l        [3        U5       Vs/ s H  o" U SU S35      PM     snU l        S Ho  n[3        U5       Vs/ s H  nU" U SU S	U S35      PM     snU R,                  U'   [3        U5       H%  nUR9                  U R,                  U   U   S
5        M'     Mq     S HL  n[        R$                  " U[&        S9U R,                  U'   [        R0                  " U5      U R.                  U'   MN     [3        U5       Vs/ s H  o" U SU S35      PM     snU l        [3        U5       Vs/ s H  o" U SU S35      PM     snU l        S Ho  n[3        U5       Vs/ s H  nU" U SU S	U S35      PM     snU R,                  U'   [3        U5       H%  nUR9                  U R,                  U   U   S
5        M'     Mq     U R?                  5         U RA                  U5        Xpl!        Xl"        g s  snf s  snf s  snf s  snf s  snf s  snf )N._)dtype)leftrightleftcbrightcbzlefts[]zrights[zmargins[z][strong)bottomtopbottomcbtopcbzbottoms[ztops[)#kiwiVariable
parent_posparent_innerseq_idname
isinstancer   nrowsncolsnp
atleast_1dheight_ratiosoneswidth_ratiosSolversolver	add_childemptyobjectartistschildrenmarginsmargin_valszerosrangeleftsrightsaddEditVariablebottomstopsreset_marginsadd_constraintsh_padw_pad)selfparentr   r   r   r   r   r6   r7   r#   r!   r   sntodosolis                   H/var/www/html/env/lib/python3.13/site-packages/matplotlib/_layoutgrid.py__init__LayoutGrid.__init__$   st    ==$(68O	fj))!;;-q4DI

]]=9 !#DMM,7 "DYY_&*-- ++-DKT/J/ --DKxxf=%v>:D &(XXe_DT" ;
 kk;@<H<ah"VA3a01<H
=B5\J\x2$gaS 23\J:D+0<"9+7a #+bT$r!A+F"G+7"9DLL5\##DLL$6q$98D " ; ;D!#5!@DLL%'XXe_DT" ; @EU|L|!B4xs!!45|L9>uFAXE!A./F	:D+0<"9+7a #+bT$r!A+F"G+7"9DLL5\##DLL$6q$98D " ; 	V$

5 IJ"9 MF"9s$   O#O(3O-5O2!O7O<c                    SU R                   S SU R                   SU R                   S3n[        U R                  5       GH0  n[        U R                  5       GH  nX SU SU R                  U   R                  5       S S	U R                  U   R                  5       S S
U R                  U   R                  5       S SU R                  U   R                  5       S SU R                  S   U   R                  5       S SU R                  S   U   R                  5       S SU R                  S   U   R                  5       S SU R                  S   U   R                  5       S S3-  nGM     GM3     U$ )NzLayoutBox: 25s xz,
z, z: Lz1.3fz, Bz, Rz, Tz, MLr   z, MRr   z, MBr   z, MTr   z, 
)
r   r   r   r.   r/   valuer2   r0   r3   r+   )r8   strr=   js       r>   __repr__LayoutGrid.__repr__i   s}   DIIc?!DJJ<qCHtzz"A4::&Bqc "::a=..06 7<<?00248 9;;q>//1$7 899Q<--/5 6 LL0399;DA B LL1!4::<TB C LL215;;=dC D LL/288:4@F F ' # 
    c                 :    S H  nU R                  US5        M     g)z
Reset all the margins to zero.  Must do this after changing
figure size, for instance, because the relative size of the
axes labels etc changes.
)r   r   r   r   r   r   r   r   g        N)edit_margins)r8   r;   s     r>   r4   LayoutGrid.reset_marginsx   s    ?DdC(?rJ   c                 f    U R                  5         U R                  U5        U R                  5         g N)hard_constraintsparent_constraintsgrid_constraints)r8   r9   s     r>   r5   LayoutGrid.add_constraints   s*    ' 	rJ   c                 8   [        U R                  5       H  nU R                  U   U R                  U   :  U R                  U   U R                  S   U   -
  U R                  S   U   -
  U R                  U   U R                  S   U   -
  U R                  S   U   -
  :  /nU H!  nU R
                  R                  US-  5        M#     M     [        U R                  5       H  nU R                  U   U R                  U   :  U R                  U   U R                  S   U   -
  U R                  S   U   -
  U R                  U   U R                  S   U   -
  U R                  S	   U   -
  :  /nU H!  nU R
                  R                  US-  5        M#     M     g
)zW
These are the redundant constraints, plus ones that make the
rest of the code easier.
r   r   r   r   requiredr   r   r   r   N)
r.   r   r0   r/   r+   r%   addConstraintr   r3   r2   )r8   r=   hccs       r>   rP   LayoutGrid.hard_constraints   s   
 tzz"A++a.DJJqM1;;q>DLL$9!$<<LL+A./JJqMDLL$8$;;LL*1-..B ))!j.9  # tzz"A))A,$,,q/199Q<$,,u"5a"88LL)!,-LLOdll8&<Q&??LL,Q/00B ))!j.9  #rJ   c                     XR                   [        R                  " [        R                  " U5      [        R                  " U5      5      '   g rO   )r*   r   ix_r    )r8   childr=   rG   s       r>   r&   LayoutGrid.add_child   s+    DIbffR]]1-r}}Q/?@ArJ   c                 ^   [        U[        5      (       d`  U R                  S   US   :H  U R                  S   US   US   -   :H  U R                  S   US   US   -   :H  U R
                  S   US   :H  /nGOU R                  u  p4[        R                  " U5      n[        R                  " U5      nUR                  US      nUR                  US      nUR                  US      nUR
                  US      nU R                  (       a  XQR                  S   US      -  nXQR                  S   US      -  nXaR                  S   US      -  nXaR                  S	   US      -  nXqR                  S
   US      -  nXqR                  S   US      -  nXR                  S   US      -  nXR                  S   US      -  nU R                  S   U:H  U R                  S   U:H  U R                  S   U:H  U R
                  S   U:H  /nU H!  n	U R                  R                  U	S-  5        M#     g )Nr            r   r   r   r   r   r   r   r   rU   )r   r   r/   r0   r3   r2   r   r   r    r   r+   r%   rV   )
r8   r9   rW   rowscolsr   r   r   r   rX   s
             r>   rQ   LayoutGrid.parent_constraints   s1   
 &*--**Q-6!9,++b/VAY%::))A,&)fQi"77,,r"fQi/	1B JD==&D==&D<<Q(DMM$r(+E++d1g&C^^DH-F   v.tAw77x0a990b::	248<<~~e,T!W55~~g.tAw77..248<<..4T"X>>**Q-4'++b/U*))A,#%,,r"f,	.B
 AKK%%a*n5 rJ   c                    U R                   S   U R                  S   S   -
  U R                  S   S   -
  nXR                  S   -
  U R                  S   S   -
  U R                  S   S   -
  nXR                  S   -  n[	        SU R
                  5       H  nU R                   U   U R                  S   U   -
  U R                  S   U   -
  nXR                  U   -
  U R                  S   U   -
  U R                  S   U   -
  nXU R                  U   -  :H  nU R                  R                  US-  5        U R                   US-
     U R                  U   :H  nU R                  R                  US-  5        M     U R                  S   U R                  S   S   -
  U R                  S	   S   -
  nXPR                  S   -
  U R                  S
   S   -
  U R                  S   S   -
  nXPR                  S   -  n[	        SU R                  5       H  nU R                  U   U R                  S   U   -
  U R                  S	   U   -
  nXPR                  U   -
  U R                  S
   U   -
  U R                  S   U   -
  nXVU R                  U   -  :H  nU R                  R                  US-  5        U R                  US-
     U R                  U   :H  nU R                  R                  US-  5        M     g )Nr   r   r   r   r   ra   r   r   r   r   r   )r0   r+   r/   r#   r.   r   r%   rV   r3   r2   r!   r   )r8   ww0r=   rX   hh0s          r>   rR   LayoutGrid.grid_constraints   s   
 [[^dll73A66\\)$Q'(Af!5a!88\\(#A&'""1%%q$**%AQ$,,w"7"::i(+,AZZ]"T\\&%9!%<<h'*+A4,,Q///AKK%%a(l3QU#tzz!}4AKK%%a(l3 & IIaL4<<.q11DLL4I!4LLa 4<<#9!#<<\\*%a()##A&&q$**%A1U 3A 66g&q)*A\\!_$t||H'=a'@@j)!,-A4--a000AKK%%a(l3a!e$		!4AKK%%a(l3 &rJ   c                 ~    U R                   R                  U R                  U   U   U5        X R                  U   U'   g)aG  
Change the size of the margin for one cell.

Parameters
----------
todo : string (one of 'left', 'right', 'bottom', 'top')
    margin to alter.

size : float
    Size of the margin.  If it is larger than the existing minimum it
    updates the margin size. Fraction of figure size.

cell : int
    Cell column or row to edit.
N)r%   suggestValuer+   r,   r8   r;   sizecells       r>   edit_marginLayoutGrid.edit_margin   s9      	  d!3D!94@'+t$rJ   c                 T    X R                   U   U   :  a  U R                  XU5        gg)a\  
Change the minimum size of the margin for one cell.

Parameters
----------
todo : string (one of 'left', 'right', 'bottom', 'top')
    margin to alter.

size : float
    Minimum size of the margin .  If it is larger than the
    existing minimum it updates the margin size. Fraction of
    figure size.

cell : int
    Cell column or row to edit.
N)r,   rq   rn   s       r>   edit_margin_minLayoutGrid.edit_margin_min  s/    $ ""4(..T. /rJ   c                 x    [        [        U R                  U   5      5       H  nU R                  XU5        M     g)z
Change the size of all the margin of all the cells in the layout grid.

Parameters
----------
todo : string (one of 'left', 'right', 'bottom', 'top')
    margin to alter.

size : float
    Size to set the margins.  Fraction of figure size.
N)r.   lenr,   rq   r8   r;   ro   r=   s       r>   rL   LayoutGrid.edit_margins"  s3     s4++D123AT+ 4rJ   c                 x    [        [        U R                  U   5      5       H  nU R                  XU5        M     g)a@  
Change the minimum size of all the margin of all
the cells in the layout grid.

Parameters
----------
todo : {'left', 'right', 'bottom', 'top'}
    The margin to alter.

size : float
    Minimum size of the margin.  If it is larger than the
    existing minimum it updates the margin size. Fraction of
    figure size.
N)r.   rw   r,   rt   rx   s       r>   edit_all_margins_minLayoutGrid.edit_all_margins_min2  s3      s4++D123A  Q/ 4rJ   c                    U R                  SUS   UR                  R                  5        U R                  SUS   UR                  R                  5        U R                  SUS   UR                  R                  S-
  5        U R                  SUS   UR                  R                  S-
  5        U R                  SUS   UR                  R                  5        U R                  SUS   UR                  R                  5        U R                  SUS   UR                  R                  S-
  5        U R                  S	US	   UR                  R                  S-
  5        g
)z
Edit all four margin minimums in one statement.

Parameters
----------
margin : dict
    size of margins in a dict with keys 'left', 'right', 'bottom',
    'top'

ss : SubplotSpec
    defines the subplotspec these margins should be applied to
r   r   r   ra   r   r   r   r   r   N)rt   colspanstartstoprowspan)r8   marginsss      r>   edit_outer_margin_mins!LayoutGrid.edit_outer_margin_minsE  s    	VVF^RZZ5E5EFXvh'79I9IJWfWorzz7JKYy(92::??Q;NOUF5M2::3C3CDWfWorzz7G7GHXvh'719LMZ
);ZZ__q0	2rJ   c                 &    U R                   U   U   $ )z"Return the margin at this position)r,   )r8   r;   cols      r>   get_marginsLayoutGrid.get_margins^  s    %c**rJ   c                    [         R                  " U5      n[         R                  " U5      n[        R                  " U R                  US      R                  5       U R                  US      R                  5       U R                  US      R                  5       U R                  US      R                  5       5      nU$ )zi
Return the outer bounding box of the subplot specs
given by rows and cols.  rows and cols can be spans.
r   r_   )	r   r    r   from_extentsr/   rE   r2   r0   r3   r8   rc   rd   bboxs       r>   get_outer_bboxLayoutGrid.get_outer_bboxb  s    
 }}T"}}T"  JJtAw%%'LLb"((*KKR!'')IId1g$$&	(
 rJ   c           	         [         R                  " U5      n[         R                  " U5      n[        R                  " U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  S   US      R                  5       -   U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  S   US      R                  5       -   U R                  US      R                  5       U R                  S   US      R                  5       -
  U R                  S   US      R                  5       -
  U R                  US      R                  5       U R                  S	   US      R                  5       -
  U R                  S
   US      R                  5       -
  5      nU$ )zi
Return the inner bounding box of the subplot specs
given by rows and cols.  rows and cols can be spans.
r   r   r   r_   r   r   r   r   r   r   
r   r    r   r   r/   rE   r+   r2   r0   r3   r   s       r>   get_inner_bboxLayoutGrid.get_inner_bboxq  s   
 }}T"}}T"  ZZQ &&(V$T!W-3356X&tAw/5578 \\$r(#))+X&tBx06689Z(b288:; [[b"((*W%d2h/5578Y'R1779: YYtAw%%'U#DG,2245W%d1g.4467
 rJ   c           	         [         R                  " U5      n[         R                  " U5      n[        R                  " U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  US      R                  5       U R                  S   US      R                  5       -
  U R                  US      R                  5       U R                  S   US      R                  5       -
  5      nU$ )zR
Return the bounding box that includes the
decorations but, *not* the colorbar...
r   r   r_   r   r   r   r   r   s       r>   get_bbox_for_cbLayoutGrid.get_bbox_for_cb  s'   
 }}T"}}T"  ZZQ &&(X&tAw/5578\\$r(#))+Z(b288:;[[b"((*Y'R1779:YYtAw%%'W%d1g.4467	
 rJ   c                 X   [         R                  " U5      n[         R                  " U5      n[        R                  " U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  US      R                  5       U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  S   US      R                  5       -   U R                  US      R                  5       5      nU$ )o
Return the left margin bounding box of the subplot specs
given by rows and cols.  rows and cols can be spans.
r   r   r_   r   )	r   r    r   r   r/   rE   r+   r2   r3   r   s       r>   get_left_margin_bboxLayoutGrid.get_left_margin_bbox  s   
 }}T"}}T"  ZZQ &&(X&tAw/5578\\$r(#))+ZZQ &&(X&tAw/5578V$T!W-3356 YYtAw%%'* rJ   c           	      X   [         R                  " U5      n[         R                  " U5      n[        R                  " U R                  US      R                  5       U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  US      R                  5       U R                  US      R                  5       U R                  S   US      R                  5       -   U R                  S   US      R                  5       -   5      nU$ )r   r   r_   r   r   )	r   r    r   r   r/   rE   r2   r+   r0   r   s       r>   get_bottom_margin_bbox!LayoutGrid.get_bottom_margin_bbox  s   
 }}T"}}T"  ZZQ &&(\\$r(#))+\\*%d2h/5578[[b"((*\\$r(#))+X&tBx06689\\*%d2h/5578 rJ   c                 X   [         R                  " U5      n[         R                  " U5      n[        R                  " U R                  US      R                  5       U R                  S   US      R                  5       -
  U R                  S   US      R                  5       -
  U R                  US      R                  5       U R                  US      R                  5       U R                  S   US      R                  5       -
  U R                  US      R                  5       5      nU$ )r   r_   r   r   r   )	r   r    r   r   r0   rE   r+   r2   r3   r   s       r>   get_right_margin_bbox LayoutGrid.get_right_margin_bbox  s   
 }}T"}}T"  [[b"((*W%d2h/5578Y'R1779: \\$r(#))+[[b"((*Y'R1779:YYtAw%%'* rJ   c           	      X   [         R                  " U5      n[         R                  " U5      n[        R                  " U R                  US      R                  5       U R                  US      R                  5       U R                  S   US      R                  5       -
  U R                  US      R                  5       U R                  US      R                  5       U R                  S   US      R                  5       -
  U R                  S   US      R                  5       -
  5      nU$ )r   r   r   r_   r   )	r   r    r   r   r/   rE   r3   r+   r0   r   s       r>   get_top_margin_bboxLayoutGrid.get_top_margin_bbox  s   
 }}T"}}T"  ZZQ &&(YYtAw%%'W%d1g.4467[[b"((*YYtAw%%'W%d1g.4467U#DG,22457 rJ   c                 8    U R                   R                  5         g)zB
Update the variables for the solver attached to this layoutgrid.
N)r%   updateVariables)r8   s    r>   update_variablesLayoutGrid.update_variables  s     	##%rJ   )r)   r2   r*   r6   r!   r/   r,   r+   r   r   r   r   r   r0   r%   r3   r7   r#   )
Nr   F ra   ra   NNNN)r   )__name__
__module____qualname____firstlineno____doc__r?   rH   r4   r5   rP   r&   rQ   rR   rq   rt   rL   r{   r   r   r   r   r   r   r   r   r   r   __static_attributes__ rJ   r>   r   r      s     06=>6:#CJ) :2J&6P%4T,&/*, 0&22+0($&$$&rJ   r   c                  &    S[        [        5      -  $ )z5Generate a short sequential id for layoutbox objects.z%06d)next_layoutboxobjnumr   rJ   r>   r   r     s    D)***rJ   c                    Uc#  U R                  5       R                  U 5      nX0   n[        R                  S   R	                  5       S   nXB   n[        UR                  5       GHu  n[        UR                  5       GHW  nUR                  XgS9nU R                  [        R                  " UR                  UR                  UR                  SSSSU R                  SS	9	5        UR!                  XgS9n	U R                  [        R                  " U	R                  U	R                  U	R                  S
USU R                  SS95        UR#                  XgS9n	U R                  [        R                  " U	R                  U	R                  U	R                  SSS/ SQU R                  SS9	5        UR%                  XgS9n	U R                  [        R                  " U	R                  U	R                  U	R                  SSS/ SQU R                  SS9	5        UR'                  XgS9n	U R                  [        R                  " U	R                  U	R                  U	R                  SSS/ SQU R                  SS9	5        UR)                  XgS9n	U R                  [        R                  " U	R                  U	R                  U	R                  SSS/ SQU R                  SS9	5        GMZ     GMx     UR*                  R,                   H  n
U
c  M  [/        X
US-   S9  M     g)z(Simple plotting to show where boxes are.Nzaxes.prop_cyclecolor)rc   rd   ra   z0.7皙?)	linewidth	edgecolor	facecoloralpha	transformzorderr`   none)r   r   r   r   r   r   )      ?ffffff?r   )r   r   r   r   r   r   )r   r   r   )r   r   r   )r   r   r   )level)get_layout_engineexecutemplrcParamsby_keyr.   r   r   r   
add_artistmpatches	Rectanglep0widthheighttransFigurer   r   r   r   r   r*   flatplot_children)figlgr   _layoutgridscolorsr   r=   rG   bbbbichs              r>   r   r     s   	z,,.66s;\\+,335g>F
-C288_rxxA"""2BNN""255"((BII-2e),*,./
 ###3CNN""366399cjjA-0F-0__RIJ
 ))q)9CNN""366399cjjA-33-<-0__RIJ
 ***:CNN""366399cjjA-33-<-0__RIJ
 +++;CNN""366399cjjA-33-<-0__RIJ
 ((a(8CNN""366399cjjA-33-<-0__RIJA ! L kk>#q1 rJ   )Nr   )r   	itertools
kiwisolverr   loggingnumpyr   
matplotlibr   matplotlib.patchespatchesr   matplotlib.transformsr   	getLoggerr   _logr   countr   r   r   r   rJ   r>   <module>r      sW   $      % &"K& K&Z ??$ +
/2rJ   