a
    ëÝEbêJ  ã                
   @   s¤  d dl Zd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZ drdd„Zdsdd	„Zed
gƒdd„ ƒZedgƒdd„ ƒZedgƒdd„ ƒZedgƒdd„ ƒZedgdd�dd„ ƒZedgdd�dd„ ƒZdd„ Zed gƒd!d"„ ƒZed#gƒd$d%„ ƒZed&gƒd'd(„ ƒZed)gƒd*d+„ ƒZed,gƒd-d.„ ƒZed/gƒd0d1„ ƒZed2gd3d�d4d5„ ƒZed6gƒd7d8„ ƒZ ed9gƒd:d;„ ƒZ!ed<gƒd=d>„ ƒZ"ed?gƒd@dA„ ƒZ#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHdI„ Z'dJdK„ Z(dLdM„ Z)edNgdOdPdQ�dRdS„ ƒZ*dTdU„ Z+dVdW„ Z,edXgddPdQ�dYdZ„ ƒZ-ed[gddPdQ�d\d]„ ƒZ.d^d_„ Z/ed`gdOdPdadbidc�ddde„ ƒZ0edfgdOdPdae 1dgd gdhdigg¡idc�djdk„ ƒZ2dldm„ Z3dndo„ Z4dpdq„ Z5dS )té    N)Úimage_comparison)ÚtickerÚrcParamsé   Fc                 C   sb   |   ddg¡ | jdd� |sJ| jd|d� | jd|d� | jd|d� n|  g ¡ |  g ¡ d S )	Né   é   é   ©Znbinsúx-label©Úfontsizeúy-labelÚTitle)ÚplotZlocator_paramsÚ
set_xlabelÚ
set_ylabelÚ	set_titleÚset_xticklabelsÚset_yticklabels)Úaxr   Únodec© r   úg/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/tests/test_constrainedlayout.pyÚexample_plot   s    
r   c              	   C   s¼   d\}}t jtdd| |ƒtdd| |ƒf \}}d|d  |d  |d  t  |d  |d  ¡ }| j|||d d…d d…f d	d
ddd�}| jd|d� | jd|d� | jd|d� |S )N)ç333333ã?r   éýÿÿÿr   r   ç       @é   r   éÿÿÿÿZRdBu_rg      ð¿ç      ð?T)ZcmapZvminZvmaxZ
rasterizedr
   r   r   r   )ÚnpZmgridÚsliceÚexpÚ
pcolormeshr   r   r   )r   r   ZdxZdyÚyÚxÚzÚpcmr   r   r   Úexample_pcolor   s    ÿ
4 ÿr(   zconstrained_layout1.pngc                  C   s$   t jdd�} |  ¡ }t|dd� dS )z,Test constrained_layout for a single subplotT©Úconstrained_layouté   r   N)ÚpltÚfigureÚadd_subplotr   ©Úfigr   r   r   r   Útest_constrained_layout1$   s    r1   zconstrained_layout2.pngc                  C   s0   t jdddd�\} }|jD ]}t|dd� qdS )z(Test constrained_layout for 2x2 subplotsr   Tr)   r+   r   N)r,   ÚsubplotsÚflatr   ©r0   Úaxsr   r   r   r   Útest_constrained_layout2,   s    
r6   zconstrained_layout3.pngc                  C   sZ   t jdddd�\} }t|jƒD ]6\}}t|dd�}|dkr@d}nd}| j|||d	� qd
S )z3Test constrained_layout for colorbars with subplotsr   Tr)   r+   r   r   g{®Gáz´?ç{®Gáz”?)r   ÚpadN)r,   r2   Ú	enumerater3   r(   Úcolorbar)r0   r5   Únnr   r'   r8   r   r   r   Útest_constrained_layout34   s    r<   zconstrained_layout4.pngc                  C   sB   t jdddd�\} }|jD ]}t|dd�}q| j||ddd� d	S )
z;Test constrained_layout for a single colorbar with subplotsr   Tr)   r+   r   ç{®Gáz„?r   ©r   r8   ÚshrinkN©r,   r2   r3   r(   r:   ©r0   r5   r   r'   r   r   r   Útest_constrained_layout4B   s    
rB   zconstrained_layout5.pnggü©ñÒMb`?)Ztolc                  C   sF   t jdddd�\} }|jD ]}t|dd�}q| j||dddd	d
� dS )zZ
    Test constrained_layout for a single colorbar with subplots,
    colorbar bottom
    r   Tr)   r+   r   Fr=   r   Úbottom)r   Zuse_gridspecr8   r?   ÚlocationNr@   rA   r   r   r   Útest_constrained_layout5L   s    
þrE   zconstrained_layout6.pngc               	   C   sÎ   dt jd< t jdd�} | jdd| d�}|d  dd¡}|d  dd¡}g }|D ]$}|  |¡}||g7 }t|d	d
� qN| d¡ g }|D ]$}|  |¡}||g7 }t|d	d
�}q†| j	||dddt
jdd�d� dS )z,Test constrained_layout for nested gridspecsFúpcolormesh.snapTr)   r   r   ©r-   r   r   r   zx-label
MultiLiner=   g®Gáz®ï?rC   r   r	   )r   r8   r?   rD   ZticksN)r,   r   r-   Úadd_gridspecÚsubgridspecr.   r   r   r(   r:   r   ZMaxNLocator)r0   ÚgsÚgslÚgsrZaxslr   Zaxsrr'   r   r   r   Útest_constrained_layout6[   s(    






þrM   c                  C   sŠ   t jtdd��h tjdd�} t dd¡}t dd|d ¡}t dd|d ¡}|D ]}|  |¡ qP|  	¡  W d  ƒ n1 s|0    Y  dS )	z2Test for proper warning if fig not set in GridSpeczhThere are no gridspecs with layoutgrids. Possibly did not call parent GridSpec with the "figure" keyword©ÚmatchTr)   r   r   r   N)
ÚpytestZwarnsÚUserWarningr,   r-   ÚgridspecÚGridSpecÚGridSpecFromSubplotSpecr.   Údraw_without_rendering)r0   rJ   rK   rL   r   r   r   Útest_constrained_layout7v   s    ÿrV   zconstrained_layout8.pngc                  C   sæ   t jddd�} tjdd| d�}g }dD ]|}|dkr:d	g}ndd
g}|D ]Z}|  |||f ¡}||g7 }t|dd�}|dkr„| d¡ |d	k r–| d¡ | d¡ qFq&|  |ddd…f ¡}||g7 }t|dd�}| j	||ddd� dS )z/Test for gridspecs that are not completely full)é
   r   T©Úfigsizer*   r   r   rG   ©r   r   r   r   é   é	   r   Ú r   Nr=   r   r>   )
r,   r-   rR   rS   r.   r(   r   r   r   r:   )r0   rJ   r5   ÚjZilistÚir   r'   r   r   r   Útest_constrained_layout8†   s(    



r`   zconstrained_layout9.pngc                  C   sr   t jdddddd�\} }|jD ]$}t|dd�}| d¡ | d¡ q| d¡ | j||d	d
d� | jddd� dS )z4Test for handling suptitle and for sharex and shareyr   TF)r*   ÚsharexÚshareyr+   r   r]   r   r=   r   r>   zTest Suptitleé   N)	r,   r2   r3   r(   r   r   Ú
set_aspectr:   ÚsuptitlerA   r   r   r   Útest_constrained_layout9¢   s    
ÿ



rf   zconstrained_layout10.pngc                  C   sF   t jdddd�\} }|jD ]}|jt d¡dd� q|jddd	� d
S )z%Test for handling legend outside axisr   Tr)   r   zThis is a label)Úlabelzcenter left)gš™™™™™é?ç      à?)ÚlocZbbox_to_anchorN)r,   r2   r3   r   r    ZarangeZlegendr4   r   r   r   Útest_constrained_layout10±   s    
rj   zconstrained_layout11.pngc                  C   sº   t jddd�} tjdd| d�}t dd|d ¡}t dd|d ¡}|  |d ¡}t|dd	� g }|D ]$}|  |¡}||g7 }t|dd	�}qd| j||d
dd� |  |d ¡}t|dd	� dS )z"Test for multiple nested gridspecsT)é   r   ©r*   rY   r   r   rG   r   r\   r   r   ç     €Q@©r   r?   ÚaspectN©	r,   r-   rR   rS   rT   r.   r   r(   r:   ©r0   Úgs0rK   Zgsl0r   r5   rJ   r'   r   r   r   Útest_constrained_layout11º   s    

rs   zconstrained_layout11rat.pngc                  C   sÈ   t jddd�} tjdd| ddgd�}t dd|d ¡}tjdd|d ddgd	�}|  |d ¡}t|d
d� g }|D ]$}|  |¡}||g7 }t|d
d�}qr| j||ddd� |  |d ¡}t|d
d� dS )z4Test for multiple nested gridspecs with width_ratiosT)rW   r   rl   r   r   é   )r-   Zwidth_ratiosr   )Úheight_ratiosr\   r   r   rm   rn   Nrp   rq   r   r   r   Útest_constrained_layout11ratÎ   s    

rv   zconstrained_layout12.pngc                  C   sÖ   t jddd�} tjdd| d�}|  |dd…d	f ¡}|  |dd…d	f ¡}t|d
d� t|d
d� |  |dd…df ¡}t|dd� |  |dd…df ¡}t|dd� |  |dd…df ¡}t|dd� | d¡ dS )z/Test that very unbalanced labeling still works.T)rt   é   rl   rt   r   rG   Nr   r   é   r   r   )r   r[   r
   )r,   r-   rR   rS   r.   r   r   )r0   rr   Úax1Úax2r   r   r   r   Útest_constrained_layout12â   s    r{   zconstrained_layout13.pngr7   c                  C   sŽ   t jdddd�\} }|jD ]$}t|dd�}| j||dddd	� qtjtd
d�� | jddd� W d  ƒ n1 sr0    Y  | jddd� dS )úTest that padding works.r   Tr)   r   r   r   ç      4@r7   ©r   r?   ro   r8   zunexpected keyword argumentrN   r   )ZwpadZhpadNgUUUUUUÕ?)Úw_padÚh_pad)	r,   r2   r3   r(   r:   rP   ZraisesÚ	TypeErrorÚset_constrained_layout_padsrA   r   r   r   Útest_constrained_layout13ø   s    
,rƒ   zconstrained_layout14.pngc                  C   sV   t jdddd�\} }|jD ]$}t|dd�}| j||dddd	� q| jd
d
ddd� dS )r|   r   Tr)   r   r   r   r}   r7   r~   gUUUUUU¥?çš™™™™™É?©r   r€   ZhspaceZwspaceN)r,   r2   r3   r(   r:   r‚   rA   r   r   r   Útest_constrained_layout14  s    
þr†   zconstrained_layout15.pngc                  C   s4   dt d< t dd¡\} }|jD ]}t|dd� qdS )zTest that rcparams work.Tzfigure.constrained_layout.user   r   r   N)r   r,   r2   r3   r   r4   r   r   r   Útest_constrained_layout15  s    
r‡   zconstrained_layout16.pngc                  C   s.   t jdd�\} }t|dd� |  g d¢¡}dS )zTest ax.set_position.Tr)   r   r   )r„   r„   çš™™™™™Ù?rˆ   N)r,   r2   r   Úadd_axes©r0   r   rz   r   r   r   Útest_constrained_layout16  s    r‹   zconstrained_layout17.pngc                  C   s”   t jdd�} tjdd| d�}|  |d ¡}|  |ddd…f ¡}|  |dd…dd	…f ¡}|  |dd…d
f ¡}t|ƒ t|ƒ t|ƒ t|ƒ dS )zTest uneven gridspecsTr)   r   rG   ©r   r   r   r   Nr   r   )r,   r-   rR   rS   r.   r   )r0   rJ   ry   rz   Úax3Zax4r   r   r   Útest_constrained_layout17!  s    rŽ   c                  C   sT   t jdd�\} }| ¡ }t|ƒ t|dd� |  ¡  t| ¡ j| ¡ jkƒsPJ ‚dS )z
Test twinxTr)   r+   r   N)r,   r2   Ztwinxr   rU   ÚallÚget_positionÚextentsrŠ   r   r   r   Útest_constrained_layout182  s    r’   c                  C   sh   t jdd�\} }| ¡ }t|ƒ t|dd� | d¡ | d¡ |  ¡  t| ¡ j| ¡ jkƒsdJ ‚dS )z
Test twinyTr)   r+   r   r]   N)	r,   r2   Ztwinyr   r   rU   r�   r�   r‘   rŠ   r   r   r   Útest_constrained_layout19<  s    

r“   c                  C   sh   t  ddd¡} t  | | dd…df ¡}t ¡ }| g d¢¡}| | | |dd…dd…f ¡}| |¡ dS )z)Smoke test cl does not mess up added axeséûÿÿÿr   r[   N)r   r   r   r   r   )r    ZlinspaceÚhypotr,   r-   r‰   r#   r:   )ZgxÚimgr0   r   Zmeshr   r   r   Útest_constrained_layout20H  s    r—   c                  C   sf   t jdd�\} }|  d¡ |  ¡  t | ¡ j¡}|  d¡ |  ¡  t | ¡ j¡}tj 	||¡ dS )z>#11035: repeated calls to suptitle should not alter the layoutTr)   Z	Suptitle0Z	Suptitle1N)
r,   r2   re   rU   r    Úcopyr�   r‘   ÚtestingÚassert_allclose©r0   r   Zextents0Úextents1r   r   r   Útest_constrained_layout21S  s    

r�   c                  C   s`   t jdd�\} }|  ¡  t | ¡ j¡}| jddd� |  ¡  t | ¡ j¡}tj 	||¡ dS )zC#11035: suptitle should not be include in CL if manually positionedTr)   ZSuptitlerh   ©r$   N)
r,   r2   rU   r    r˜   r�   r‘   re   r™   rš   r›   r   r   r   Útest_constrained_layout22b  s    rŸ   c                  C   sN   t dƒD ]@} tjdddd�}| dd¡}|d  dd¡}| d | ¡¡ qdS )	zu
    Comment in #11035: suptitle used to cause an exception when
    reusing a figure w/ CL with ``clear=True``.
    r   TZ123)r*   ÚclearÚnumr   r   z
Suptitle{}N)Úranger,   r-   rH   rI   re   Úformat)r_   r0   rJ   Úsubr   r   r   Útest_constrained_layout23p  s
    r¥   ztest_colorbar_location.pngTZmpl20)Úremove_textÚstylec                  C   sö   dt jd< t jdddd�\} }|jD ] }t|ƒ}| d¡ | d¡ q$| j||dd…d	f d
d� | j||ddd…f ddd� | j||ddd…f dddd� | j||ddd…f ddd� | j||d ddd� | j||d	d…df ddd� dS )zY
    Test that colorbar handling is as expected for various complicated
    cases...
    FrF   r[   r   Tr)   r]   Nr   rˆ   )r   r?   r   r   rh   rC   )r   r?   rD   r   gš™™™™™©?)r   r?   rD   r8   éþÿÿÿr   ÚtoprŒ   ÚleftÚright)r,   r   r2   r3   r(   r   r   r:   rA   r   r   r   Útest_colorbar_location}  s    


 r¬   c                  C   sX   t jdddd�\} }|d  d¡ |  ¡  t |d  ¡ j¡}tjj	|g d¢dd	� d S )
Nr   Tr)   rZ   FrŒ   )g›çˆ|—R§?g\å	„�bá?g&�Ñ:ªšÞ?g³Ñ9?Åqï?çñhãˆµøä>)Úrtol)
r,   r2   Zset_visiblerU   r    r˜   r�   r‘   r™   rš   )r0   r5   rœ   r   r   r   Útest_hidden_axes”  s    
ÿr¯   c               	   C   sr  dD �]f} t jdddd�\}}g }t|jƒD ]€\}}|jdd� t|ƒ}|j||| ddd	�}||g7 }|jjdd� |d
kr,|jj 	g ¡ |jj
 	g ¡ | g ¡ | g ¡ q,|jddddd� | ¡  | dv �r tj |d j ¡ j|d j ¡ j¡ tj |d
 j ¡ j|d j ¡ j¡ qtj |d j ¡ j|d
 j ¡ j¡ tj |d j ¡ j|d j ¡ j¡ qd S )N)r«   rª   r©   rC   r   Tr)   Úin)Ú	directionr   g{®Gáz¤?)r   rD   r?   r8   r   gÇqÇq¬?gš™™™™™¹?r…   )rª   r«   r   r   )r,   r2   r9   r3   Útick_paramsr(   r:   r   ZxaxisZ	set_ticksÚyaxisr   r   r‚   rU   r    r™   rš   r�   Úx0Úy0)rD   r0   r5   Zcbsr;   r   ÚpcÚcbr   r   r   Útest_colorbar_align¡  sB    
ÿ


ÿ
ÿÿÿÿr¸   ztest_colorbars_no_overlapV.pngc                  C   s|   t jddd�} | jddddd�}|D ]H}|j t ¡ ¡ |jddd	� | ddgd
dgg¡}| j	||dd� q$|  
d¡ d S )N)r   r[   TrX   r   r   ©ra   rb   Úbothr°   ©Zaxisr±   r   r[   Úvertical©r   ZorientationÚfoo)r,   r-   r2   r³   Úset_major_formatterr   ÚNullFormatterr²   Úimshowr:   re   ©r0   r5   r   Zimr   r   r   Útest_colorbars_no_overlapVÁ  s    rÃ   ztest_colorbars_no_overlapH.pngc                  C   s|   t jddd�} |  d¡ | jddddd�}|D ]H}|j t ¡ ¡ |jdd	d
� | 	ddgddgg¡}| j
||dd� q.d S )N)r[   r   TrX   r¾   r   r   r¹   rº   r°   r»   r   r[   Ú
horizontalr½   )r,   r-   re   r2   r³   r¿   r   rÀ   r²   rÁ   r:   rÂ   r   r   r   Útest_colorbars_no_overlapHÎ  s    
rÅ   c                  C   sÖ   t jdddd�\} }|d  g d¢¡ |  ¡  |d  ¡ }tj |ddgddgg¡ t jdddd�\} }|d  g d¢¡ |d  tj	 
d	d	¡¡}| j||d d
� |  ¡  |d  ¡ }tj |ddgddgg¡ d S )Nr   r   Tr)   r   )r„   r„   ç333333Ó?rÆ   r„   rh   é   )r   g)\�Âõ(Ü?)r,   r2   Zset_positionrU   r�   r    r™   rš   r#   ÚrandomZrandr:   )r0   r5   Úppr¶   r   r   r   Útest_manually_set_positionÛ  s    rÊ   ztest_bboxtight.pngZbbox_inchesZtight)r¦   r§   Zsavefig_kwargc                  C   s   t jdd�\} }| d¡ d S ©NTr)   r   ©r,   r2   rd   r/   r   r   r   Útest_bboxtightë  s    rÍ   ztest_bbox.pngrh   g      @r   c                  C   s   t jdd�\} }| d¡ d S rË   rÌ   r/   r   r   r   Ú	test_bboxó  s    rÎ   c                  C   sà   t jddddddid�\} \}}}| dd¡ | d	¡ | d
d¡ | d	¡ | dd¡ | d	¡ | j|||fd� |  ¡  |jj ¡ |jj ¡ |jj ¡ g}t	j
j|d j|d jg|d jddd� |d jdksÜJ ‚dS )zî
    Tests for a bug in which constrained layout and align_ylabels on
    three unevenly sized subplots, one of whose y tick labels include
    negative numbers, drives the non-negative subplots' y labels off
    the edge of the plot
    r   r   T)gš™™™™™@rw   ru   )r   r   gffffffæ?)r*   rY   Zgridspec_kwr   ÚLabelg      ø¿g      ø?)r5   r   r­   )r®   ZatolN)r,   r2   Zset_ylimr   Zalign_ylabelsrU   r³   rg   Zget_window_extentr    r™   rš   r´   )r0   r�   ry   rz   Zafter_alignr   r   r   Útest_align_labelsü  s(    
þ





þÿrÐ   c                  C   s  t jdd�\} }|  ¡  | | j ¡ ¡}|  d¡ |  d¡ |  ¡  | | j ¡ ¡}|j|jd kshJ ‚|j	|j	d ks|J ‚t jdd�\} }|  ¡  | | j ¡ ¡}| jddd� | jddd� |  ¡  | | j ¡ ¡}|j|jd ksìJ ‚|j	|j	d k�sJ ‚d S )	NTr)   ÚBooZBooyg      $@rh   )r%   rž   )
r,   r2   rU   Zget_tightbboxZcanvasZget_rendererZ	supxlabelZ	supylabelrµ   r´   )r0   r   Zpos0Úposr   r   r   Útest_suplabels  s$    

rÓ   c                  C   s:   t  ¡ } |  dd¡}|  |dd …dd …f ¡}|  ¡  d S )Nr   r   r   )r,   r-   rH   r.   rU   )r0   rJ   Úspr   r   r   Útest_gridspec_addressing5  s    rÕ   )r   F)r   )6Únumpyr    rP   Zmatplotlib.testing.decoratorsr   Zmatplotlib.pyplotZpyplotr,   Zmatplotlib.gridspecrR   Zmatplotlib.transformsZ
transformsZmtransformsZ
matplotlibr   r   r   r(   r1   r6   r<   rB   rE   rM   rV   r`   rf   rj   rs   rv   r{   rƒ   r†   r‡   r‹   rŽ   r’   r“   r—   r�   rŸ   r¥   r¬   r¯   r¸   rÃ   rÅ   rÊ   rÍ   ZBboxrÎ   rÐ   rÓ   rÕ   r   r   r   r   Ú<module>   sž   





	













ÿ
 ÿ
ÿ
þ
ÿþ
"