B
    ·ôJd{  ã               @   sö   d Z 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 ddlmZ ddlmZ ddlmZ G dd„ dejƒZG d	d
„ d
ejƒZG dd„ dejƒZG dd„ de
ƒZeeƒ edgdddd„ ƒZedgdddd„ ƒZ dS )z)
Testing that skewed axes properly work.
é    )Ú	ExitStackN)Úimage_comparison)ÚAxes)Úregister_projectionc                   s$   e Zd Z‡ fdd„Zdd„ Z‡  ZS )Ú	SkewXTickc          	      sÖ   t ƒ Æ}x2| j| j| j| j| jgD ]}| |j| ¡ ¡ q"W t	 
| jj|  ¡ ¡}t	 
| jj|  ¡ ¡}| j | j ¡ ov|¡ | j | j ¡ oŒ|¡ | j | j ¡ o¢|¡ | j | j ¡ o¸|¡ tƒ  |¡ W d Q R X d S )N)r   ZgridlineZ	tick1lineZ	tick2lineÚlabel1Úlabel2ÚcallbackZset_visibleZget_visibleÚ
transformsZinterval_containsÚaxesÚ
lower_xlimZget_locÚ
upper_xlimÚsuperÚdraw)ÚselfÚrendererÚstackZartistZneeds_lowerZneeds_upper)Ú	__class__© úL/var/www/html/venv/lib/python3.7/site-packages/matplotlib/tests/test_skew.pyr      s"    zSkewXTick.drawc             C   s   | j j ¡ S )N)r   ÚxaxisÚget_view_interval)r   r   r   r   r   )   s    zSkewXTick.get_view_interval)Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   r   )r   r   r      s   r   c               @   s   e Zd Zdd„ Zdd„ ZdS )Ú	SkewXAxisc             C   s   t | jd |dS )N)Úmajor)r   r   )r   r   r   r   r   Ú	_get_tick0   s    zSkewXAxis._get_tickc             C   s   | j jd | j jd fS )Nr   é   )r   r   r   )r   r   r   r   r   3   s    zSkewXAxis.get_view_intervalN)r   r   r   r   r   r   r   r   r   r   /   s   r   c               @   s   e Zd Zdd„ ZdS )Ú	SkewSpinec             C   s@   | j j}| jdkr(| jj|d d …df< n| jj|d d …df< d S )NÚtopr   )Ú_pathZverticesZ
spine_typer   r   r   )r   Úptsr   r   r   Ú_adjust_location;   s    
zSkewSpine._adjust_locationN)r   r   r   r$   r   r   r   r   r    :   s   r    c                   sH   e Zd ZdZdd„ Zdd„ Z‡ fdd„Zedd	„ ƒZed
d„ ƒZ	‡  Z
S )Ú	SkewXAxesÚskewxc             C   sZ   t | ƒ| _| jj | j¡ | jj | j¡ t | ¡| _| jj	 | j¡ | jj
 | j¡ d S )N)r   r   Úspinesr!   Zregister_axisÚbottomÚmaxisZYAxisZyaxisÚleftÚright)r   r   r   r   Ú
_init_axisK   s    
zSkewXAxes._init_axisc             C   s8   t  | d¡tj | d¡tj | d¡tj | d¡dœ}|S )Nr!   r(   r*   r+   )r!   r(   r*   r+   )r    Zlinear_spineÚmspinesÚSpine)r   r'   r   r   r   Ú_gen_axes_spinesT   s
    
zSkewXAxes._gen_axes_spinesc                sn   d}t ƒ  ¡  | j| jt ¡  |d¡  | _| j| j | _	t 
| j| j t ¡ ¡t ¡  |d¡ | j | _dS )z
        This is called once when the plot is created to set up all the
        transforms for the data, text and grids.
        é   r   N)r   Ú_set_lim_and_transformsZ
transScaleZtransLimitsr
   ÚAffine2DÚskew_degÚtransDataToAxesZ	transAxesÚ	transDataZblended_transform_factoryZIdentityTransformZ_xaxis_transform)r   Zrot)r   r   r   r1   [   s    

z!SkewXAxes._set_lim_and_transformsc             C   s
   | j jjS )N)r   ZviewLimZ	intervalx)r   r   r   r   r   x   s    zSkewXAxes.lower_xlimc             C   s,   ddgddgg}| j  ¡  |¡d d …df S )Ng        g      ð?r   )r4   ÚinvertedÚ	transform)r   r#   r   r   r   r   |   s    zSkewXAxes.upper_xlim)r   r   r   Únamer,   r/   r1   Úpropertyr   r   r   r   r   )r   r   r%   F   s   	r%   Z	skew_axesT)Zremove_textc              C   sN   t  ¡ } | jddddd}| dd¡ | dd¡ | d¡ |jddd	 d S )
Nr   r&   )Z
projectioniÎÿÿÿé2   Tr   Úb)Úcolor)ÚpltZfigureZadd_subplotÚset_xlimÚset_ylimÚgridZaxvline)ZfigÚaxr   r   r   Útest_set_line_coll_dash_image‡   s    
rB   Z
skew_rectsc        	      C   sþ   t jdddddd\} }|j}ttjddddd	gd
dƒ}|d  dd	g¡ |d  dd	g¡ |d jddd xtt	||ƒD ]f\}\}}d| d|  }}t
 ¡  ||¡}| d ||¡¡ | tjddgd
d
||j ddd¡ q|W t jdddddd d S )Né   T)é   rD   )ZsharexZshareyZfigsizeéýÿÿÿéÿÿÿÿr   r   é   é   )ÚrepeatÚequal)Zshareé-   zSkew of {0} in X and {1} in Yg      à?Zcoral)r7   ÚalphaZ	facecolorg{®Gáz„?g®Gáz®ï?)Zwspacer*   r+   r(   r!   )r=   ZsubplotsZflatÚlistÚ	itertoolsÚproductr>   r?   Z
set_aspectÚzipr
   r2   r3   Ú	set_titleÚformatZ	add_patchÚmpatchZ	Rectangler5   Zsubplots_adjust)	Zfixr   Z	rotationsrA   ZxrotsZyrotsZxdegZydegÚtr   r   r   Útest_skew_rectangle“   s    rU   )!Ú__doc__Ú
contextlibr   rN   Zmatplotlib.pyplotZpyplotr=   Zmatplotlib.testing.decoratorsr   Zmatplotlib.axesr   Zmatplotlib.transformsr
   Zmatplotlib.axisZaxisr)   Zmatplotlib.spinesr'   r-   Zmatplotlib.patchesZpatchesrS   Zmatplotlib.projectionsr   ZXTickr   ZXAxisr   r.   r    r%   rB   rU   r   r   r   r   Ú<module>   s"   >