3
$ßL]Æ  ã               @   sì   d Z ddlmZ ddlZddlj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j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|j|jƒ ƒ q"W t	j
| jj| jƒ ƒ}t	j
| jj| jƒ ƒ}| jj| jjƒ ov|ƒ | jj| jjƒ oŒ|ƒ | jj| jjƒ o¢|ƒ | jj| jjƒ o¸|ƒ tt| ƒj|ƒ 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Úsuperr   Údraw)ÚselfZrendererÚstackZartistZneeds_lowerZneeds_upper)Ú	__class__© úB/tmp/pip-install-edjban26/matplotlib/matplotlib/tests/test_skew.pyr      s"    zSkewXTick.drawc             C   s   | j 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|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               @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zedd	„ ƒZed
d„ ƒZ	dS )Ú	SkewXAxesÚskewxc             C   sb   t | ƒ| _| jd j| jƒ | jd j| jƒ tj| ƒ| _| jd j| jƒ | jd j| jƒ d S )Nr!   ÚbottomÚleftÚright)r   r   ÚspinesZregister_axisÚmaxisZYAxisZyaxis)r   r   r   r   Ú
_init_axisL   s    
zSkewXAxes._init_axisc             C   s8   t j| dƒtjj| dƒtjj| dƒtj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_spinesU   s
    
zSkewXAxes._gen_axes_spinesc             C   sn   d}t j| ƒ | j| jtjƒ j|dƒ  | _| j| j | _	tj
| j| j tjƒ ƒtjƒ j|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rotr   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   y   s    zSkewXAxes.lower_xlimc             C   s,   ddgddgg}| j jƒ j|ƒd d …df S )Ng        g      ð?r   )r4   ÚinvertedÚ	transform)r   r#   r   r   r   r   }   s    zSkewXAxes.upper_xlimN)
r   r   r   Únamer,   r/   r1   Úpropertyr   r   r   r   r   r   r%   F   s   	r%   Z	skew_axesT)Zbaseline_imagesZremove_textc              C   sN   t jƒ } | jddddd�}|jd	dƒ |jdd
ƒ |jdƒ |jddd� d S )Nr   r&   )Z
projectioné2   Tr   Úb)ÚcoloriÎÿÿÿiÎÿÿÿ)ÚpltÚfigureZadd_subplotÚset_xlimÚset_ylimZ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 jddgƒ |d jddgƒ |d jd
dd� xtt	||ƒD ]f\}\}}d| d|  }}t
jƒ j||ƒ}|jdj||ƒƒ |j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é   )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!   )rD   rD   éýÿÿÿéÿÿÿÿrK   rK   rL   rL   )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"   




?