§
    †ÛgGW  ã                   ó°   — d Z ddlZddlZddlZddlZddlZddl	m
Z ddlmZ  ej        e¦  «        Z G d„ d¦  «        Z ej        ¦   «         Zd„ Zdd„ZdS )	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                   ó²   — e Zd ZdZ	 	 	 	 dd„Zd„ Zd	„ Zd
„ Zd„ Zdd„Z	d„ Z
d„ Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd„ ZdS ) Ú
LayoutGridzG
    Analogous to a gridspec, and contained in another LayoutGrid.
    N©r   r   FÚ é   c                 ó
  ‡‡‡— t           j        Š|| _        || _        || _        |t          ¦   «         z   | _        t          |t          ¦  «        r|j        › d| j        › �| _        || _	        || _
        t          j        |
¦  «        | _        |
€t          j        |¦  «        | _        t          j        |	¦  «        | _        |	€t          j        |¦  «        | _        | j        dz   Št          |t          ¦  «        s || _        t          j        ¦   «         | _        n&|| _         |j        | g|¢R Ž  | j        j        | _        t          j        ||ft(          ¬¦  «        | _        t          j        ||ft(          ¬¦  «        | _        i | _        i | _        dD ]Št          j        |¦  «        | j        ‰<   Œ| j        }ˆˆfd„t5          |¦  «        D ¦   «         | _        ˆˆfd„t5          |¦  «        D ¦   «         | _        ˆˆfd„t5          |¦  «        D ¦   «         | _        ˆˆfd„t5          |¦  «        D ¦   «         | _        dD ]`Šˆˆˆfd	„t5          |¦  «        D ¦   «         | j        ‰<   t5          |¦  «        D ])}|                     | j        ‰         |         d
¦  «         Œ*ŒadD ]AŠt          j        |t(          ¬¦  «        | j        ‰<   t          j        |¦  «        | j        ‰<   ŒBˆˆfd„t5          |¦  «        D ¦   «         | _         ˆˆfd„t5          |¦  «        D ¦   «         | _!        ˆˆfd„t5          |¦  «        D ¦   «         | _"        ˆˆfd„t5          |¦  «        D ¦   «         | _#        dD ]`Šˆˆˆfd„t5          |¦  «        D ¦   «         | j        ‰<   t5          |¦  «        D ])}|                     | j        ‰         |         d
¦  «         Œ*Œa|  $                    ¦   «          |  %                    ¦   «          || _&        || _'        d S )Nú.Ú_)Údtype)ÚleftÚrightÚleftcbÚrightcbc                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )zwidths[ú]© ©Ú.0ÚiÚVariableÚsns     €€úL/granary/edev/quantum/lib/python3.11/site-packages/matplotlib/_layoutgrid.pyú
<listcomp>z'LayoutGrid.__init__.<locals>.<listcomp>S   ó4   ø€ ÐJÐJÐJ¸�x�x 2Ð 2Ð 2¨aÐ 2Ð 2Ð 2Ñ3Ô3ÐJÐJÐJó    c                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )zlefts[r   r   r   s     €€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>T   s4   ø€ ÐHÐHÐH°a�h�h "Ð0Ð0¨AÐ0Ð0Ð0Ñ1Ô1ÐHÐHÐHr   c                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )zrights[r   r   r   s     €€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>U   r   r   c                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )zinner_widths[r   r   r   s     €€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>V   sD   ø€ ð 4ð 4ð 4Ø!"ð &˜X¨Ð&>Ð&>¸!Ð&>Ð&>Ð&>Ñ?Ô?ð 4ð 4ð 4r   c           
      ó8   •— g | ]} ‰‰› d ‰› d|› d�¦  «        ‘ŒS ©zmargins[z][r   r   ©r   r   r   r   Útodos     €€€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>Y   óL   ø€ ð "9ð "9ð "9Ø&'ð #+ (¨bÐ+FÐ+F¸$Ð+FÐ+FÀ!Ð+FÐ+FÐ+FÑ"GÔ"Gð "9ð "9ð "9r   Ústrong)ÚbottomÚtopÚbottomcbÚtopcbc                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )zheights[r   r   r   s     €€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>b   ó4   ø€ ÐLÐLÐL¸!˜˜ BÐ!4Ð!4°Ð!4Ð!4Ð!4Ñ5Ô5ÐLÐLÐLr   c                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )zinner_heights[r   r   r   s     €€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>c   sD   ø€ ð 5ð 5ð 5Ø"#ð '˜h¨"Ð'@Ð'@¸AÐ'@Ð'@Ð'@ÑAÔAð 5ð 5ð 5r   c                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )zbottoms[r   r   r   s     €€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>e   r+   r   c                 ó2   •— g | ]} ‰‰› d |› d�¦  «        ‘ŒS )ztops[r   r   r   s     €€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>f   s4   ø€ ÐFÐFÐF°A�X�X Ð.Ð.¨!Ð.Ð.Ð.Ñ/Ô/ÐFÐFÐFr   c           
      ó8   •— g | ]} ‰‰› d ‰› d|› d�¦  «        ‘ŒS r!   r   r"   s     €€€r   r   z'LayoutGrid.__init__.<locals>.<listcomp>h   r$   r   )(Úkiwir   ÚparentÚ
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ÚwidthsÚleftsÚrightsÚinner_widthsÚaddEditVariableÚheightsÚinner_heightsÚbottomsÚtopsÚreset_marginsÚadd_constraintsÚh_padÚw_pad)Úselfr1   r2   r3   r5   r8   r7   rT   rU   r=   r;   Úsolr   r   r   r#   s                @@@r   Ú__init__zLayoutGrid.__init__$   sy  øøø€ õ ”=ˆØˆŒØ$ˆŒØ(ˆÔØ�6™8œ8‘OˆŒ	Ý�f�jÑ)Ô)ð 	5Ø!œ;Ð4Ð4¨¬Ð4Ð4ˆDŒIØˆŒ
ØˆŒ
Ýœ]¨=Ñ9Ô9ˆÔØÐ Ý!#¤¨¡¤ˆDÔÝœM¨,Ñ7Ô7ˆÔØÐÝ "¤¨¡¤ˆDÔàŒY˜‰_ˆÝ˜&¥*Ñ-Ô-ð 	-ð !ˆDŒKÝœ+™-œ-ˆDŒKˆKà ˆDŒKØˆFÔ˜TÐ/ JÐ/Ð/Ð/Ð/Øœ+Ô,ˆDŒKå”x ¨ µfÐ=Ñ=Ô=ˆŒÝœ %¨ µvÐ>Ñ>Ô>ˆŒàˆŒØˆÔà:ð 	5ð 	5ˆDõ &(¤X¨e¡_¤_ˆDÔ˜TÑ"Ð"àŒkˆð
 KÐJÐJÐJÐJ½UÀ5¹\¼\ÐJÑJÔJˆŒØHÐHÐHÐHÐH½5À¹<¼<ÐHÑHÔHˆŒ
ØJÐJÐJÐJÐJ½UÀ5¹\¼\ÐJÑJÔJˆŒð4ð 4ð 4ð 4ð 4Ý&+¨E¡l¤lð4ñ 4ô 4ˆÔà:ð 	Eð 	EˆDð"9ð "9ð "9ð "9ð "9ð "9Ý+0°©<¬<ð"9ñ "9ô "9ˆDŒL˜Ñå˜5‘\”\ð Eð E�Ø×#Ò# D¤L°Ô$6°qÔ$9¸8ÑDÔDÐDÐDðEð ;ð 	5ð 	5ˆDÝ!#¤¨5½Ð!@Ñ!@Ô!@ˆDŒL˜ÑÝ%'¤X¨e¡_¤_ˆDÔ˜TÑ"Ð"àLÐLÐLÐLÐL½uÀU¹|¼|ÐLÑLÔLˆŒð5ð 5ð 5ð 5ð 5Ý',¨U¡|¤|ð5ñ 5ô 5ˆÔàLÐLÐLÐLÐL½uÀU¹|¼|ÐLÑLÔLˆŒØFÐFÐFÐFÐF½¸u¹¼ÐFÑFÔFˆŒ	Ø:ð 	Eð 	EˆDð"9ð "9ð "9ð "9ð "9ð "9Ý+0°©<¬<ð"9ñ "9ô "9ˆDŒL˜Ñå˜5‘\”\ð Eð E�Ø×#Ò# D¤L°Ô$6°qÔ$9¸8ÑDÔDÐDÐDðEð
 	×ÒÑÔÐØ×ÒÑÔÐàˆŒ
ØˆŒ
ˆ
ˆ
r   c                 óà  — d| j         d›d| j        › d| j        › d�}t          | j        ¦  «        D �];}t          | j        ¦  «        D �]"}||› d|› d| j        |                              ¦   «         d›d	| j        |                              ¦   «         d›d
| j        |                              ¦   «         d›d| j        |                              ¦   «         d›d| j	        |                              ¦   «         d›d| j
        |                              ¦   «         d›d| j        d         |                              ¦   «         d›d| j        d         |                              ¦   «         d›d�z  }�Œ$�Œ=|S )NzLayoutBox: Ú25sú Úxz,
z, z: L(z1.3fz, Bz, Wz, Hz, innerWz, innerHz, MLr   z, MRr   z, 
)r5   r7   r8   rH   rJ   ÚvaluerP   rI   rN   rL   rO   rE   )rV   Ústrr   Újs       r   Ú__repr__zLayoutGrid.__repr__u   sÙ  € ØH˜DœIÐHÐHÐH¨D¬JÐHÐH¸¼ÐHÐHÐHˆÝ�t”zÑ"Ô"ð 
	Hñ 
	HˆAÝ˜4œ:Ñ&Ô&ð 	Hñ 	H�Ø˜!ð Hð H˜qð Hð HØ œJ qœM×/Ò/Ñ1Ô1Ð:ðHð Hàœ<¨œ?×0Ò0Ñ2Ô2Ð;ðHð Hð  œ; qœ>×/Ò/Ñ1Ô1Ð:ðHð Hð  œ<¨œ?×0Ò0Ñ2Ô2Ð;ð	Hð Hð
 !%Ô 1°!Ô 4× :Ò :Ñ <Ô <ÐEðHð Hð !%Ô 2°1Ô 5× ;Ò ;Ñ =Ô =ÐFðHð Hð !œL¨Ô0°Ô3×9Ò9Ñ;Ô;ÐDðHð Hð !œL¨Ô1°!Ô4×:Ò:Ñ<Ô<ÐGðHð Hð Hñ H�‘ñ	Hð ˆ
r   c                 ó<   — dD ]}|                       |d¦  «         ŒdS )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)rV   r#   s     r   rR   zLayoutGrid.reset_margins„   s6   € ð?ð 	)ð 	)ˆDà×Ò˜d CÑ(Ô(Ð(Ð(ð	)ð 	)r   c                 ó~   — |                       ¦   «          |                      ¦   «          |                      ¦   «          d S ©N)Úhard_constraintsÚparent_constraintsÚgrid_constraints©rV   s    r   rS   zLayoutGrid.add_constraintsŽ   s@   € à×ÒÑÔÐà×ÒÑ!Ô!Ð!ð 	×ÒÑÔÐÐÐr   c                 ó
  — t          | j        ¦  «        D ]¬}| j        |         | j        |         k    | j        |         | j        d         |         z
  | j        d         |         z
  | j        |         | j        d         |         z
  | j        d         |         z
  k    g}|D ]}| j                             |dz  ¦  «         Œ Œ­t          | j        ¦  «        D ]¬}| j        |         | j	        |         k    | j        |         | j        d         |         z
  | j        d         |         z
  | j	        |         | j        d         |         z
  | j        d	         |         z
  k    g}|D ]}| j                             |dz  ¦  «         Œ Œ­d
S )zo
        These are the redundant constraints, plus ones that make the
        rest of the code easier.
        r   r   r   r   Úrequiredr'   r)   r&   r(   N)
rH   r8   rK   rJ   rE   r?   ÚaddConstraintr7   rQ   rP   )rV   r   ÚhcÚcs       r   re   zLayoutGrid.hard_constraints—   s   € õ
 �t”zÑ"Ô"ð 	:ð 	:ˆAØ”+˜a”. D¤J¨q¤MÒ1Ø”;˜q”> D¤L°Ô$9¸!Ô$<Ñ<Ø”L Ô+¨AÔ.ñ/à”J˜q”M D¤L°Ô$8¸Ô$;Ñ;Ø”L Ô*¨1Ô-ñ.ò.ðˆBð ð :ð :�Ø”×)Ò)¨!¨j©.Ñ9Ô9Ð9Ð9ð:õ �t”zÑ"Ô"ð 	:ð 	:ˆAØ”)˜A”, $¤,¨q¤/Ò1Ø”9˜Q”< $¤,¨uÔ"5°aÔ"8Ñ8Ø”L Ô)¨!Ô,ñ-à”L ”O d¤l°8Ô&<¸QÔ&?Ñ?Ø”L Ô,¨QÔ/ñ0ò0ðˆBð ð :ð :�Ø”×)Ò)¨!¨j©.Ñ9Ô9Ð9Ð9ð:ð	:ð 	:r   r   c                 óˆ   — || j         t          j        t          j        |¦  «        t          j        |¦  «        ¦  «        <   d S rd   )rD   r9   Úix_r:   )rV   Úchildr   r_   s       r   r@   zLayoutGrid.add_child°   s4   € àDIˆŒ•b”f�Rœ]¨1Ñ-Ô-­r¬}¸QÑ/?Ô/?Ñ@Ô@ÑAÐAÐAr   c                 ó¬  — | j         }t          |t          ¦  «        sn| j        d         |d         k    | j        d         |d         |d         z   k    | j        d         |d         |d         z   k    | j        d         |d         k    g}�n§| j        \  }}t          j	        |¦  «        }t          j	        |¦  «        }|j        |d                  }|j        |d                  }|j        |d                  }|j        |d                  }| j
        rà||j        d         |d                  z  }||j        d         |d                  z  }||j        d         |d                  z  }||j        d	         |d                  z  }||j        d
         |d                  z  }||j        d         |d                  z  }||j        d         |d                  z  }||j        d         |d                  z  }| j        d         |k    | j        d         |k    | j        d         |k    | j        d         |k    g}|D ]}	| j                             |	dz  ¦  «         Œ d S )Nr   éÿÿÿÿé   r   é   r   r   r   r   r'   r)   r&   r(   rj   )r1   r6   r   rJ   rK   rQ   rP   r2   r9   r:   r3   rE   r?   rk   )
rV   r1   rl   ÚrowsÚcolsr   r   r'   r&   rm   s
             r   rf   zLayoutGrid.parent_constraints´   sA  € ð
 ”ˆÝ˜&¥*Ñ-Ô-ð 	.à”*˜Q”- 6¨!¤9Ò,Ø”+˜b”/ V¨A¤Y°¸´Ñ%:Ò:à”)˜A”, &¨¤)¨f°Q¬iÑ"7Ò7Ø”,˜rÔ" f¨Q¤iÒ/ð	1ˆB‰Bð œ‰JˆD�$Ý”= Ñ&Ô&ˆDÝ”= Ñ&Ô&ˆDà”<  Q¤Ô(ˆDØ”M $ r¤(Ô+ˆEØ”+˜d 1œgÔ&ˆCØ”^ D¨¤HÔ-ˆFØÔ ð 
?ð ˜œ vÔ.¨t°A¬wÔ7Ñ7�Ø˜œ xÔ0°°a´Ô9Ñ9�Ø˜œ¨Ô0°°b´Ô:Ñ:�Ø˜œ¨	Ô2°4¸´8Ô<Ñ<�Ø�v”~ eÔ,¨T°!¬WÔ5Ñ5�Ø�v”~ gÔ.¨t°A¬wÔ7Ñ7�Ø˜&œ.¨Ô2°4¸´8Ô<Ñ<�Ø˜&œ.¨Ô4°T¸"´XÔ>Ñ>�Ø”*˜Q”- 4Ò'Ø”+˜b”/ UÒ*à”)˜A”, #Ò%Ø”,˜rÔ" fÒ,ð	.ˆBð
 ð 	6ð 	6ˆAØŒK×%Ò% a¨*¡nÑ5Ô5Ð5Ð5ð	6ð 	6r   c                 óÂ  — | j         d         | j        d         d         z
  | j        d         d         z
  }|| j        d         z
  | j        d         d         z
  | j        d         d         z
  }|| j        d         z  }t	          d| j        ¦  «        D ]Ü}| j         |         | j        d         |         z
  | j        d         |         z
  }|| j        |         z
  | j        d         |         z
  | j        d         |         z
  }||| j        |         z  k    }| j                             |dz  ¦  «         | j         |dz
           | j        |         k    }| j                             |dz  ¦  «         ŒÝ| j        d         | j        d         d         z
  | j        d	         d         z
  }|| j	        d         z
  | j        d
         d         z
  | j        d         d         z
  }|| j
        d         z  }t	          d| j        ¦  «        D ]Ü}| j        |         | j        d         |         z
  | j        d	         |         z
  }|| j	        |         z
  | j        d
         |         z
  | j        d         |         z
  }||| j
        |         z  k    }| j                             |dz  ¦  «         | j	        |dz
           | j        |         k    }| j                             |dz  ¦  «         ŒÝd S )Nr   r   r   r   r   r   r%   r'   r)   r&   r(   )rK   rE   rJ   r=   rH   r8   r?   rk   rQ   rP   r;   r7   )rV   ÚwÚw0r   rm   ÚhÚh0s          r   rg   zLayoutGrid.grid_constraintsÝ   sÍ  € ð
 Œ[˜Œ^˜dœl¨7Ô3°AÔ6Ñ6ØŒ\˜)Ô$ QÔ'ñ(ˆà�”˜A”Ñ ¤¨fÔ!5°aÔ!8Ñ8ØŒ\˜(Ô# AÔ&ñ'ˆà�Ô" 1Ô%Ñ%ˆå�q˜$œ*Ñ%Ô%ð 		4ð 		4ˆAØ”˜Q” $¤,¨wÔ"7¸Ô":Ñ:Ø”˜iÔ(¨Ô+ñ,ˆAà�T”Z ”]Ñ" T¤\°&Ô%9¸!Ô%<Ñ<Ø”˜hÔ'¨Ô*ñ+ˆAà�b˜4Ô,¨QÔ/Ñ/Ò/ˆAØŒK×%Ò% a¨(¡lÑ3Ô3Ð3à”˜Q ™UÔ# t¤z°!¤}Ò4ˆAØŒK×%Ò% a¨(¡lÑ3Ô3Ð3Ð3ð ŒI�aŒL˜4œ<¨Ô.¨qÔ1Ñ1°D´LÀÔ4IÈ!Ô4LÑLˆØ�”˜a”Ñ  4¤<°Ô#9¸!Ô#<Ñ<ØŒ\˜*Ô% aÔ(ñ)ˆà�Ô# AÔ&Ñ&ˆå�q˜$œ*Ñ%Ô%ð 		4ð 		4ˆAØ”˜1” ¤¨UÔ 3°AÔ 6Ñ6Ø”˜gÔ& qÔ)ñ*ˆAà�T”\ !”_Ñ$ t¤|°HÔ'=¸aÔ'@Ñ@Ø”˜jÔ)¨!Ô,ñ-ˆAà�b˜4Ô-¨aÔ0Ñ0Ò0ˆAØŒK×%Ò% a¨(¡lÑ3Ô3Ð3à”˜a !™eÔ$¨¬	°!¬Ò4ˆAØŒK×%Ò% a¨(¡lÑ3Ô3Ð3Ð3ð		4ð 		4r   c                 ó~   — | j                              | j        |         |         |¦  «         || j        |         |<   dS )aŸ  
        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?   ÚsuggestValuerE   rF   ©rV   r#   ÚsizeÚcells       r   Úedit_marginzLayoutGrid.edit_margin  s@   € ð  	Œ× Ò  ¤¨dÔ!3°DÔ!9¸4Ñ@Ô@Ð@Ø'+ˆÔ˜Ô˜tÑ$Ð$Ð$r   c                 óf   — || j         |         |         k    r|                      |||¦  «         dS dS )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)rF   r�   r~   s       r   Úedit_margin_minzLayoutGrid.edit_margin_min  sB   € ð$ �$Ô" 4Ô(¨Ô.Ò.Ð.Ø×Ò˜T 4¨Ñ.Ô.Ð.Ð.Ð.ð /Ð.r   c                 óˆ   — t          t          | j        |         ¦  «        ¦  «        D ]}|                      |||¦  «         ŒdS )a1  
        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)rH   ÚlenrF   r�   ©rV   r#   r   r   s       r   rb   zLayoutGrid.edit_margins/  sP   € õ •s˜4Ô+¨DÔ1Ñ2Ô2Ñ3Ô3ð 	,ð 	,ˆAØ×Ò˜T 4¨Ñ+Ô+Ð+Ð+ð	,ð 	,r   c                 óˆ   — t          t          | j        |         ¦  «        ¦  «        D ]}|                      |||¦  «         ŒdS )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)rH   r…   rF   rƒ   r†   s       r   Úedit_all_margins_minzLayoutGrid.edit_all_margins_min?  sP   € õ  •s˜4Ô+¨DÔ1Ñ2Ô2Ñ3Ô3ð 	0ð 	0ˆAØ× Ò   t¨QÑ/Ô/Ð/Ð/ð	0ð 	0r   c                 óŽ  — |                       d|d         |j        j        ¦  «         |                       d|d         |j        j        ¦  «         |                       d|d         |j        j        dz
  ¦  «         |                       d|d         |j        j        dz
  ¦  «         |                       d|d         |j        j        ¦  «         |                       d|d         |j        j        ¦  «         |                       d|d         |j        j        dz
  ¦  «         |                       d	|d	         |j        j        dz
  ¦  «         d
S )a<  
        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   r   r   r'   r)   r&   r(   N)rƒ   ÚcolspanÚstartÚstopÚrowspan)rV   ÚmarginÚsss      r   Úedit_outer_margin_minsz!LayoutGrid.edit_outer_margin_minsR  s1  € ð 	×Ò˜V V¨F¤^°R´ZÔ5EÑFÔFÐFØ×Ò˜X v¨hÔ'7¸¼Ô9IÑJÔJÐJØ×Ò˜W f¨W¤o°r´z´ÈÑ7JÑKÔKÐKØ×Ò˜Y¨¨yÔ(9¸2¼:¼?ÈQÑ;NÑOÔOÐOà×Ò˜U F¨5¤M°2´:Ô3CÑDÔDÐDØ×Ò˜W f¨W¤o°r´zÔ7GÑHÔHÐHØ×Ò˜X v¨hÔ'7¸¼¼È1Ñ9LÑMÔMÐMØ×Ò˜Z¨°
Ô);ØœZœ_¨qÑ0ñ	2ô 	2ð 	2ð 	2ð 	2r   c                 ó(   — | j         |         |         S )z"Return the margin at this position)rF   )rV   r#   Úcols      r   Úget_marginszLayoutGrid.get_marginsk  s   € àÔ Ô% cÔ*Ð*r   c                 óœ  — t          j        |¦  «        }t          j        |¦  «        }t          j        | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        |d                                       ¦   «         ¦  «        }|S )z�
        Return the outer bounding box of the subplot specs
        given by rows and cols.  rows and cols can be spans.
        r   rr   )	r9   r:   r   Úfrom_extentsrJ   r]   rP   rK   rQ   ©rV   ru   rv   Úbboxs       r   Úget_outer_bboxzLayoutGrid.get_outer_bboxo  s£   € õ
 Œ}˜TÑ"Ô"ˆÝŒ}˜TÑ"Ô"ˆåÔ ØŒJ�t˜A”wÔ×%Ò%Ñ'Ô'ØŒL˜˜bœÔ"×(Ò(Ñ*Ô*ØŒK˜˜RœÔ!×'Ò'Ñ)Ô)ØŒI�d˜1”gÔ×$Ò$Ñ&Ô&ñ	(ô (ˆð
 ˆr   c           	      ó\  — t          j        |¦  «        }t          j        |¦  «        }t          j        | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        d         |d                                       ¦   «         z   | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        d         |d                                       ¦   «         z   | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z
  | j        d         |d                                       ¦   «         z
  | j	        |d                                       ¦   «         | j        d	         |d                                       ¦   «         z
  | j        d
         |d                                       ¦   «         z
  ¦  «        }|S )z�
        Return the inner bounding box of the subplot specs
        given by rows and cols.  rows and cols can be spans.
        r   r   r   rr   r&   r(   r   r   r'   r)   ©
r9   r:   r   r•   rJ   r]   rE   rP   rK   rQ   r–   s       r   Úget_inner_bboxzLayoutGrid.get_inner_bbox~  sÉ  € õ
 Œ}˜TÑ"Ô"ˆÝŒ}˜TÑ"Ô"ˆåÔ ØŒZ˜˜QœÔ ×&Ò&Ñ(Ô(Ø”˜VÔ$ T¨!¤WÔ-×3Ò3Ñ5Ô5ñ6à”˜XÔ& t¨A¤wÔ/×5Ò5Ñ7Ô7ñ8ð Œ\˜$˜rœ(Ô#×)Ò)Ñ+Ô+Ø”˜XÔ& t¨B¤xÔ0×6Ò6Ñ8Ô8ñ9à”˜ZÔ(¨¨b¬Ô2×8Ò8Ñ:Ô:ñ;ð Œ[˜˜bœÔ"×(Ò(Ñ*Ô*Ø”˜WÔ% d¨2¤hÔ/×5Ò5Ñ7Ô7ñ8à”˜YÔ'¨¨R¬Ô1×7Ò7Ñ9Ô9ñ:ð ŒY�t˜A”wÔ×%Ò%Ñ'Ô'Ø”˜UÔ# D¨¤GÔ,×2Ò2Ñ4Ô4ñ5à”˜WÔ% d¨1¤gÔ.×4Ò4Ñ6Ô6ñ7ñ
ô 
ˆð ˆr   c           	      óü  — t          j        |¦  «        }t          j        |¦  «        }t          j        | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z
  | j	        |d                                       ¦   «         | j        d         |d                                       ¦   «         z
  ¦  «        }|S )zj
        Return the bounding box that includes the
        decorations but, *not* the colorbar...
        r   r   rr   r(   r   r)   rš   r–   s       r   Úget_bbox_for_cbzLayoutGrid.get_bbox_for_cb–  s3  € õ
 Œ}˜TÑ"Ô"ˆÝŒ}˜TÑ"Ô"ˆåÔ ØŒZ˜˜QœÔ ×&Ò&Ñ(Ô(Ø”˜XÔ& t¨A¤wÔ/×5Ò5Ñ7Ô7ñ8àŒ\˜$˜rœ(Ô#×)Ò)Ñ+Ô+Ø”˜ZÔ(¨¨b¬Ô2×8Ò8Ñ:Ô:ñ;àŒ[˜˜bœÔ"×(Ò(Ñ*Ô*Ø”˜YÔ'¨¨R¬Ô1×7Ò7Ñ9Ô9ñ:àŒY�t˜A”wÔ×%Ò%Ñ'Ô'Ø”˜WÔ% d¨1¤gÔ.×4Ò4Ñ6Ô6ñ7ñ	
ô 	
ˆð ˆr   c                 ó¤  — t          j        |¦  «        }t          j        |¦  «        }t          j        | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        d         |d                                       ¦   «         z   | j        |d                                       ¦   «         ¦  «        }|S )ú‡
        Return the left margin bounding box of the subplot specs
        given by rows and cols.  rows and cols can be spans.
        r   r   rr   r   )	r9   r:   r   r•   rJ   r]   rE   rP   rQ   r–   s       r   Úget_left_margin_bboxzLayoutGrid.get_left_margin_bboxª  s  € õ
 Œ}˜TÑ"Ô"ˆÝŒ}˜TÑ"Ô"ˆåÔ ØŒZ˜˜QœÔ ×&Ò&Ñ(Ô(Ø”˜XÔ& t¨A¤wÔ/×5Ò5Ñ7Ô7ñ8àŒ\˜$˜rœ(Ô#×)Ò)Ñ+Ô+ØŒZ˜˜QœÔ ×&Ò&Ñ(Ô(Ø”˜XÔ& t¨A¤wÔ/×5Ò5Ñ7Ô7ñ8à”˜VÔ$ T¨!¤WÔ-×3Ò3Ñ5Ô5ñ6ð ŒY�t˜A”wÔ×%Ò%Ñ'Ô'ñ*ô *ˆð ˆr   c           	      ó¤  — t          j        |¦  «        }t          j        |¦  «        }t          j        | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z   | j        d         |d                                       ¦   «         z   ¦  «        }|S )rŸ   r   rr   r(   r&   )	r9   r:   r   r•   rJ   r]   rP   rE   rK   r–   s       r   Úget_bottom_margin_bboxz!LayoutGrid.get_bottom_margin_bbox¼  s  € õ
 Œ}˜TÑ"Ô"ˆÝŒ}˜TÑ"Ô"ˆåÔ ØŒZ˜˜QœÔ ×&Ò&Ñ(Ô(ØŒ\˜$˜rœ(Ô#×)Ò)Ñ+Ô+ØŒ\˜*Ô% d¨2¤hÔ/×5Ò5Ñ7Ô7ñ8àŒ[˜˜bœÔ"×(Ò(Ñ*Ô*ØŒ\˜$˜rœ(Ô#×)Ò)Ñ+Ô+Ø”˜XÔ& t¨B¤xÔ0×6Ò6Ñ8Ô8ñ9àŒ\˜*Ô% d¨2¤hÔ/×5Ò5Ñ7Ô7ñ8ñô ˆð ˆr   c                 ó¤  — t          j        |¦  «        }t          j        |¦  «        }t          j        | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z
  | j        d         |d                                       ¦   «         z
  | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z
  | j        |d                                       ¦   «         ¦  «        }|S )rŸ   rr   r   r   r   )	r9   r:   r   r•   rK   r]   rE   rP   rQ   r–   s       r   Úget_right_margin_bboxz LayoutGrid.get_right_margin_bboxÏ  s  € õ
 Œ}˜TÑ"Ô"ˆÝŒ}˜TÑ"Ô"ˆåÔ ØŒ[˜˜bœÔ"×(Ò(Ñ*Ô*Ø”˜WÔ% d¨2¤hÔ/×5Ò5Ñ7Ô7ñ8à”˜YÔ'¨¨R¬Ô1×7Ò7Ñ9Ô9ñ:ð Œ\˜$˜rœ(Ô#×)Ò)Ñ+Ô+ØŒ[˜˜bœÔ"×(Ò(Ñ*Ô*Ø”˜YÔ'¨¨R¬Ô1×7Ò7Ñ9Ô9ñ:àŒY�t˜A”wÔ×%Ò%Ñ'Ô'ñ*ô *ˆð ˆr   c           	      ó¤  — t          j        |¦  «        }t          j        |¦  «        }t          j        | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z
  | j        |d                                       ¦   «         | j        |d                                       ¦   «         | j        d         |d                                       ¦   «         z
  | j        d         |d                                       ¦   «         z
  ¦  «        }|S )rŸ   r   r)   rr   r'   )	r9   r:   r   r•   rJ   r]   rQ   rE   rK   r–   s       r   Úget_top_margin_bboxzLayoutGrid.get_top_margin_bboxá  s  € õ
 Œ}˜TÑ"Ô"ˆÝŒ}˜TÑ"Ô"ˆåÔ ØŒZ˜˜QœÔ ×&Ò&Ñ(Ô(ØŒY�t˜A”wÔ×%Ò%Ñ'Ô'Ø”˜WÔ% d¨1¤gÔ.×4Ò4Ñ6Ô6ñ7àŒ[˜˜bœÔ"×(Ò(Ñ*Ô*ØŒY�t˜A”wÔ×%Ò%Ñ'Ô'Ø”˜WÔ% d¨1¤gÔ.×4Ò4Ñ6Ô6ñ7à”˜UÔ# D¨¤GÔ,×2Ò2Ñ4Ô4ñ5ñ7ô 7ˆð ˆr   c                 ó8   — | j                              ¦   «          dS )zR
        Update the variables for the solver attached to this layoutgrid.
        N)r?   ÚupdateVariablesrh   s    r   Úupdate_variableszLayoutGrid.update_variablesó  s   € ð 	Œ×#Ò#Ñ%Ô%Ð%Ð%Ð%r   )
Nr   Fr   r   r   NNNN)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rX   r`   rR   rS   re   r@   rf   rg   r�   rƒ   rb   rˆ   r�   r“   r˜   r›   r�   r    r¢   r¤   r¦   r©   r   r   r   r   r      s³  € € € € € ðð ð 06Ø=>Ø6:Ø#ðOð Oð Oð Oðbð ð ð)ð )ð )ð ð  ð  ð:ð :ð :ð2Jð Jð Jð Jð'6ð '6ð '6ðR%4ð %4ð %4ðT,ð ,ð ,ð&/ð /ð /ð /ð*,ð ,ð ,ð 0ð 0ð 0ð&2ð 2ð 2ð2+ð +ð +ðð ð ð ðð ð ð ð0ð ð ð ð(ð ð ð ð$ð ð ð ð&ð ð ð ð$ð ð ð ð$&ð &ð &ð &ð &r   r   c                  ó0   — dt          t          ¦  «        z  S )z5Generate a short sequential id for layoutbox objects.z%06d)ÚnextÚ_layoutboxobjnumr   r   r   r4   r4   ü  s   € à•DÕ)Ñ*Ô*Ñ*Ð*r   c                 óÎ  — |€/|                       ¦   «                              | ¦  «        }||          }t          j        d                              ¦   «         d         }||         }t          |j        ¦  «        D �]E}t          |j        ¦  «        D �],}|                     ||¬¦  «        }|  	                    t          j        |j        |j        |j        dddd| j        d¬	¦	  «	        ¦  «         |                     ||¬¦  «        }	|  	                    t          j        |	j        |	j        |	j        d
|d| j        d¬¦  «        ¦  «         |                     ||¬¦  «        }	|  	                    t          j        |	j        |	j        |	j        dddg d¢| j        d¬¦	  «	        ¦  «         |                     ||¬¦  «        }	|  	                    t          j        |	j        |	j        |	j        dddg d¢| j        d¬¦	  «	        ¦  «         |                     ||¬¦  «        }	|  	                    t          j        |	j        |	j        |	j        dddg d¢| j        d¬¦	  «	        ¦  «         |                     ||¬¦  «        }	|  	                    t          j        |	j        |	j        |	j        dddg d¢| j        d¬¦	  «	        ¦  «         �Œ.�ŒG|j        j        D ]}
|
�t/          | |
|dz   ¬¦  «         ŒdS )z(Simple plotting to show where boxes are.Nzaxes.prop_cycleÚcolor)ru   rv   r   z0.7çš™™™™™É?éýÿÿÿ)Ú	linewidthÚ	edgecolorÚ	facecolorÚalphaÚ	transformÚzorderrs   Ú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_keyrH   r7   r8   r˜   Ú
add_artistÚmpatchesÚ	RectangleÚp0ÚwidthÚheightÚtransFigurer›   r    r¤   r¢   r¦   rD   ÚflatÚplot_children)ÚfigÚlgr¿   Ú_layoutgridsÚcolorsr’   r   r_   ÚbbÚbbiÚchs              r   rÍ   rÍ     sK  € à	€zØ×,Ò,Ñ.Ô.×6Ò6°sÑ;Ô;ˆØ˜#ÔˆÝŒ\Ð+Ô,×3Ò3Ñ5Ô5°gÔ>€FØ
�Œ-€CÝ�2”8‰_Œ_ð %Jñ %JˆÝ�r”x‘”ð $	Jñ $	JˆAØ×"Ò"¨°Ð"Ñ2Ô2ˆBØ�NŠNÝÔ" 2¤5¨"¬(°B´IÈØ-2¸eØ),¸¼Ø*,ð.ñ .ô .ñ/ô /ð /ð
 ×#Ò#¨°Ð#Ñ3Ô3ˆCØ�NŠNÝÔ" 3¤6¨3¬9°c´jÈAØ-0¸FØ-0¬_ÀRðIñ Iô IñJô Jð Jð
 ×)Ò)¨q°qÐ)Ñ9Ô9ˆCØ�NŠNÝÔ" 3¤6¨3¬9°c´jÈAØ-3¸3Ø-<¨_¨_Ø-0¬_ÀRðIñ Iô IñJô Jð Jð
 ×*Ò*°¸Ð*Ñ:Ô:ˆCØ�NŠNÝÔ" 3¤6¨3¬9°c´jÈAØ-3¸3Ø-<¨_¨_Ø-0¬_ÀRðIñ Iô IñJô Jð Jð
 ×+Ò+°¸Ð+Ñ;Ô;ˆCØ�NŠNÝÔ" 3¤6¨3¬9°c´jÈAØ-3¸3Ø-<¨_¨_Ø-0¬_ÀRðIñ Iô IñJô Jð Jð
 ×(Ò(¨a°aÐ(Ñ8Ô8ˆCØ�NŠNÝÔ" 3¤6¨3¬9°c´jÈAØ-3¸3Ø-<¨_¨_Ø-0¬_ÀRðIñ Iô IñJô Jð Jñ JñA$	JðJ ŒkÔð 2ð 2ˆØˆ>Ý˜#˜r¨¨q©Ð1Ñ1Ô1Ð1øð2ð 2r   )Nr   )r­   Ú	itertoolsÚ
kiwisolverr0   ÚloggingÚnumpyr9   Ú
matplotlibrÂ   Úmatplotlib.patchesÚpatchesrÆ   Úmatplotlib.transformsr   Ú	getLoggerrª   Ú_logr   Úcountr°   r4   rÍ   r   r   r   ú<module>rà      sð   ððð ð$ Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø Ð Ð Ð à Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ø &Ð &Ð &Ð &Ð &Ð &à€wÔ˜Ñ"Ô"€ðX&ð X&ð X&ð X&ð X&ñ X&ô X&ð X&ðt #�9”?Ñ$Ô$Ð ð+ð +ð +ð
/2ð /2ð /2ð /2ð /2ð /2r   