o
    iU                     @   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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d ZdS )    )BytesION)image_comparison)FuncFormatterbbox_inches_tightTbbox_inchestight)remove_textsavefig_kwargc               	   C   s  g dg dg dg dg dg} dgd  }}t | }tt |d }g }d	}tt |}td
d
\}}	t|D ]}
|	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 )N)iR iب i{% it i}  )iv  i i0 i ir )i/\ i: iS i= i5	 )iO2 i? iL i i )ia  i i|< iD i-      g333333?g?   edgeb)bottomaligncolorr   )g333333?皙?)loc)r   r   z
lower leftbbox_to_anchorr   r   )cellText	rowLabels	colLabelsr   )lennparangezerospltsubplotsrangebarappendxticksxlimlegendreversetable)datar   r   rowsindr   widthyofffigaxrow r/   [/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/matplotlib/tests/test_bbox_tight.pytest_bbox_inches_tight   s2   


r1    bbox_inches_tight_suptile_legendFc                  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 )N   zThe number 4)intstr)yposr/   r/   r0   y_formatter6   s   z:test_bbox_inches_tight_suptile_legend.<locals>.y_formatterzX axis)r   plotr   r   r$   titlesuptitlegcayaxisset_major_formatterr   xlabel)r:   r/   r/   r0   %test_bbox_inches_tight_suptile_legend-   s   

rB   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 )Nr3   r   r   id   blueg      ?)	transform	facecoloralphag      ?)rF   )r   scatterr   r   r>   set_xlimset_ylimmpatches	Rectangle	transDatampathPathunit_regular_stardeepcopyverticesset_clip_path	transAxesgcfartistsr!   )r-   patchpathr/   r/   r0   test_bbox_inches_tight_clipping@   s   rZ   bbox_inches_tight_rasterc                  C   s(   t  } | d}|jddgdd dS )z$Test rasterization with tight_layouto         ?g       @T
rasterizedN)r   figureadd_subplotr;   r,   r-   r/   r/   r0   test_bbox_inches_tight_rasterU   s   
rc   c                  C   s@   t  \} }|jddtdfd |  | jt ddd d S )Nr
   r   nan)xyr   png)r   format)r   r   annotatefloatset_axis_offsavefigr   rb   r/   r/   r0   test_only_on_non_finite_bbox^   s   rl   c                  C   sn   t  \} }|tdd |jdd t }| j|dd |	d t 
|j\}}}||ks5J d S )Nr5   )   rm   )r   g?)ylimr   )r   r   )r   r   
pcolorfastr   r   reshapesetr   rk   seekimreadshape)r,   r-   bufheightr*   _r/   r/   r0   test_tight_pcolorfastf   s   
rx   c            	      C   s4  ddl m}  d\}}d}tjd||| || fd}t|g d}|| |  | d |	 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~J |d d d d d df dk rJ |jdksJ d S )Nr   )Image)r3      rD   F)frameondpifigsize)        r~   r]   r]   Tr^   r   pdf)r   
pad_inchesrg   )r   r         )rz   r3   r5   )PILry   r   r`   Axesadd_axesrj   	get_xaxisset_visible	get_yaxisr   r   rp   imshowrk   r   rr   asarrayopenallrt   )	ry   x_sizey_sizer|   r,   r-   r'   outimr/   r/   r0   test_noop_tight_bboxs   s&   

"&r   )ior   numpyr   matplotlib.testing.decoratorsr   matplotlib.pyplotpyplotr   matplotlib.pathrY   rO   matplotlib.patchespatchesrL   matplotlib.tickerr   r1   rB   rZ   rc   rl   rx   r   r/   r/   r/   r0   <module>   s4    



