3
$ßL]�  ã               @   sÐ   d dl Zd dlmZ d dlmZ d dljZd dl	j
Zd dljZd dlmZ edgded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edgdddid	�dd„ ƒZdd„ Zdd„ ZdS )é    N)ÚBytesIO)Úimage_comparison)ÚFuncFormatterZbbox_inches_tightTÚtight)Úbbox_inches)Zbaseline_imagesZremove_textZ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jt |ƒƒd }g }d}tjt |ƒƒ}tjddƒ\}}	xBt|ƒD ]6}
|	j|| |
 ||dd d!� || |
  }|jdgƒ q˜W tj	g ƒ tj
dgd d'd$� |jƒ  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š™™™™™Ù?é   ZedgeÚb)ÚbottomZalignÚcolorç333333ó?çš™™™™™É?)Úlocr   )ÚcellTextÚ	rowLabelsÚ	colLabelsr   )r   r   )ÚlenÚnpÚarangeÚzerosÚpltÚsubplotsÚrangeÚbarÚappendZxticksÚlegendÚreverseÚtable)Údatar   r   ZrowsÚindr   ÚwidthZyoffÚfigÚaxÚrowZ	the_table© r%   úH/tmp/pip-install-edjban26/matplotlib/matplotlib/tests/test_bbox_tight.pyÚtest_bbox_inches_tight   s,    
r'   Z bbox_inches_tight_suptile_legendFr   c              C   s`   t jtjdƒdd� t jddd� t jdƒ t jd	ƒ d
d„ } t jƒ jj	t
| ƒƒ t jdƒ d S )Né
   za straight line)ÚlabelçÍÌÌÌÌÌì?r	   z
upper left)Zbbox_to_anchorr   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_formatter4   s    z:test_bbox_inches_tight_suptile_legend.<locals>.y_formatterzX axis)r*   r	   )r   Úplotr   r   r   ÚtitleZsuptitleÚgcaZyaxisZset_major_formatterr   Zxlabel)r0   r%   r%   r&   Ú%test_bbox_inches_tight_suptile_legend+   s    

r4   Zbbox_inches_tight_clippingc              C   sš   t jtjdƒtjdƒƒ t jƒ } | jddgƒ | jddgƒ tjddgdd| j	ddd�}t
jjdƒjƒ }| jd	9  _|j|| jd
� t jƒ jj|ƒ d S )Nr(   r   r   é2   éd   Zblueg      à?)Ú	transformZ	facecolorÚalphag      Ð?)r7   iÎÿÿÿiÎÿÿÿ)r   Zscatterr   r   r3   Z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_clipping>   s    
r?   Zbbox_inches_tight_rasterc              C   s(   t jƒ } | jdƒ}|jddgdd� dS )z$Test rasterization with tight_layoutéo   g      ð?g       @T)Z
rasterizedN)r   ÚfigureZadd_subplotr1   )r"   r#   r%   r%   r&   Útest_bbox_inches_tight_rasterS   s    
rB   c              C   s@   t jƒ \} }|jddtdƒfd� |jƒ  | jtƒ ddd� d S )Nr   r   Únan)Zxyr   Zpng)r   Úformat)r   r   ZannotateÚfloatZset_axis_offÚsavefigr   )r"   r#   r%   r%   r&   Útest_only_on_non_finite_bbox\   s    rG   c              C   sn   t jƒ \} }|jtjdƒjdƒƒ |jd	d� tƒ }| j|dd� |j	dƒ t j
|ƒj\}}}||ksjt‚d S )
Nr+   é   r   çš™™™™™¹?)Zylimr   )r   )rH   rH   )r   rI   )r   r   Z
pcolorfastr   r   ZreshapeÚsetr   rF   ÚseekZimreadÚshapeÚAssertionError)r"   r#   ÚbufÚheightr!   Ú_r%   r%   r&   Útest_tight_pcolorfastd   s    
rQ   )Znumpyr   Úior   Zmatplotlib.testing.decoratorsr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.pathr>   r:   Zmatplotlib.patchesZpatchesr9   Zmatplotlib.tickerr   Údictr'   r4   r?   rB   rG   rQ   r%   r%   r%   r&   Ú<module>   s    


