U
    ÂmœdÑ  ã                   @   s  d dl m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 edgdddid	�d
d„ ƒZedgddid�dd„ ƒZedgddidd�dd„ ƒZedgdddid	�dd„ ƒZedgdddid	�dd„ ƒZdd„ Zdd„ Zdd „ Zed!gd"gdddid#�d$d%„ ƒZdS )&é    )ÚBytesION)Úimage_comparison)ÚFuncFormatterZbbox_inches_tightTÚbbox_inchesÚtight)Úremove_textÚsavefig_kwargc               	   C   s,  dddddgdddd	d
gdddddgdddddgdddddgg} dgd  }}t | ƒ}t t |ƒ¡d }g }d}t t |ƒ¡}t dd¡\}}	t|ƒD ]6}
|	j|| |
 ||dd d!� || |
  }| dg¡ q–t 	g ¡ t 
d"d¡ tjdgd d#d$� |jdgd d%d&d'� | ¡  tj|||d(d)� d S )*NiR iØ¨ i{% itÑ i}  ivã  iÓÐ iÝ0 iìƒ iÆr i/\ i¨: iîS i=™ i�5	 iO2 iÂ? i€L iïò i ia  iõ i|< iDì i-Ì  Ú é   g333333Ó?gš™™™™™Ù?é   ÚedgeÚb)ÚbottomÚalignÚcolorr   )g333333ó?çš™™™™™É?)Úloc)r   r   z
lower left©Zbbox_to_anchorr   r   )ZcellTextZ	rowLabelsZ	colLabelsr   )ÚlenÚnpÚarangeZzerosÚpltÚsubplotsÚrangeÚbarÚappendZxticksZxlimÚlegendÚreverseÚtable)ÚdataZ
col_labelsZ
row_labelsÚrowsÚindZ	cell_textÚwidthZyoffÚfigÚaxÚrow© r&   úY/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/matplotlib/tests/test_bbox_tight.pyÚtest_bbox_inches_tight   s2    ü

ÿr(   Z bbox_inches_tight_suptile_legend)r   c                  C   s`   t jt d¡dd� t jddd� t  d¡ t  d¡ d	d
„ } t  ¡ j 	t
| ƒ¡ t  d¡ d S )Né
   za straight line)Úlabel)gÍÌÌÌÌÌì?r   z
upper leftr   z
Axis titlezFigure titlec                 S   s   t | ƒdkrdS t| ƒS d S )Né   zThe number 4)ÚintÚstr)ÚyÚposr&   r&   r'   Úy_formatter6   s    z:test_bbox_inches_tight_suptile_legend.<locals>.y_formatterzX axis)r   Úplotr   r   r   ÚtitleÚsuptitleÚgcaÚyaxisZset_major_formatterr   Zxlabel)r0   r&   r&   r'   Ú%test_bbox_inches_tight_suptile_legend-   s    

r6   z)bbox_inches_tight_suptile_non_default.pngçš™™™™™¹?)r   Ztolc                  C   s    t  ¡ \} }| jdddd� d S )NZBoooç      à?gš™™™™™ñ?)Úxr.   )r   r   r3   ©r#   r$   r&   r&   r'   Ú+test_bbox_inches_tight_suptitle_non_default@   s    r;   Zbbox_inches_tight_clippingc                  C   sš   t  t d¡t d¡¡ t  ¡ } |  ddg¡ |  ddg¡ tjddgdd| j	ddd�}t
j d¡ ¡ }| jd	9  _|j|| jd
� t  ¡ j |¡ d S )Nr)   r   r
   iÎÿÿÿéd   Úbluer8   )Ú	transformZ	facecolorÚalphag      Ð?)r>   )r   Zscatterr   r   r4   Úset_xlimZset_ylimÚmpatchesZ	RectangleZ	transDataÚmpathÚPathZunit_regular_starÚdeepcopyZverticesZset_clip_pathZ	transAxesZgcfZartistsr   )r$   ÚpatchÚpathr&   r&   r'   Útest_bbox_inches_tight_clippingH   s     þrG   Zbbox_inches_tight_rasterc                  C   s"   t  ¡ \} }|jddgdd� dS )z$Test rasterization with tight_layoutç      ð?g       @T©Z
rasterizedN)r   r   r1   r:   r&   r&   r'   Útest_bbox_inches_tight_raster]   s    rJ   c                  C   s@   t  ¡ \} }|jddtdƒfd� | ¡  | jtƒ ddd� d S )Nr	   r   Únan)Zxyr   Úpng)r   Úformat)r   r   ZannotateÚfloatÚset_axis_offÚsavefigr   r:   r&   r&   r'   Útest_only_on_non_finite_bboxe   s    rQ   c                  C   sn   t  ¡ \} }| t d¡ d¡¡ |jdd� tƒ }| j|dd� | 	d¡ t  
|¡j\}}}||ksjt‚d S )Nr+   )é   rR   )r   r7   )Zylimr   )r   r   )r   r   Z
pcolorfastr   r   ÚreshapeÚsetr   rP   ÚseekZimreadÚshapeÚAssertionError)r#   r$   ÚbufÚheightr"   Ú_r&   r&   r'   Útest_tight_pcolorfastm   s    
r[   c            	      C   s8  ddl m}  d\}}d}tjd||| || fd�}t |ddddg¡}| |¡ | ¡  |j d¡ |j	 d¡ t
 || ¡ ||¡}|j|d	d
� |jtƒ dddd� tƒ }|j|ddd� | d¡ t
 |  |¡¡}|d d …d d …df dk ¡ süt‚|d d …d d …d d…f dk ¡ �r$t‚|jdk�s4t‚d S )Nr   )ÚImage)r)   é   r<   F)ZframeonÚdpiZfigsizeg        rH   TrI   r   Zpdf)r   Ú
pad_inchesrM   )r   r_   é   éÿ   )r]   r)   r+   )ZPILr\   r   ZfigureZAxesZadd_axesrO   ZxaxisZset_visibler5   r   r   rS   ZimshowrP   r   rU   ZasarrayÚopenÚallrW   rV   )	r\   Zx_sizeZy_sizer^   r#   r$   r   ÚoutZimr&   r&   r'   Útest_noop_tight_bboxz   s&    

"(re   Zbbox_inches_fixed_aspectrL   )Ú
extensionsr   r   c               	   C   sN   t  ddi¡�6 t  ¡ \} }| ddg¡ | dd¡ | d¡ W 5 Q R X d S )Nzfigure.constrained_layout.useTr   r   Úequal)r   Z
rc_contextr   r1   r@   Z
set_aspectr:   r&   r&   r'   Útest_bbox_inches_fixed_aspect—   s
    rh   )Úior   Únumpyr   Zmatplotlib.testing.decoratorsr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.pathrF   rB   Zmatplotlib.patchesZpatchesrA   Zmatplotlib.tickerr   r(   r6   r;   rG   rJ   rQ   r[   re   rh   r&   r&   r&   r'   Ú<module>   sJ   ÿ
ÿ
þ
 ÿ
 ÿ

 ÿ