o
    ¡:´a{  ã                   @   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 ƒ g}| j| j| j| j| jfD ]}| |j| ¡ ¡ qt	 
| jj|  ¡ ¡}t	 
| jj|  ¡ ¡}| j | j ¡ o9|¡ | j | j ¡ oD|¡ | j | j ¡ oO|¡ | j | j ¡ oZ|¡ tƒ  |¡ W d   ƒ d S 1 smw   Y  d S ©N)r   ZgridlineZ	tick1lineZ	tick2lineZlabel1Zlabel2ÚcallbackZset_visibleZget_visibleÚ
transformsZinterval_containsÚaxesÚ
lower_xlimZget_locÚ
upper_xlimÚsuperÚdraw)ÚselfZrendererÚstackZartistZneeds_lowerZneeds_upper©Ú	__class__© ú</usr/lib/python3/dist-packages/matplotlib/tests/test_skew.pyr      s2   ÿÿÿÿÿÿÿ"ðzSkewXTick.drawc                 C   s   | j j ¡ S r   )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   sB   | j j}| jdkr| jj|d d …df< d S | jj|d d …df< d S )NÚtopr   )Ú_pathZverticesZ
spine_typer
   r   r   ©r   Z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 r   )r   r   Úspinesr!   Zregister_axisÚbottomÚmaxisZYAxisZyaxisÚleftÚrightr   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rotr   r   r   r1   [   s    
ÿÿ
þý
ýz!SkewXAxes._set_lim_and_transformsc                 C   s
   | j jjS r   )r
   ZviewLimZ	intervalxr   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Ú	transformr#   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)Zcolor)ÚpltZfigureZadd_subplotÚset_xlimÚset_ylimZgridZaxvline)ZfigÚaxr   r   r   Útest_set_line_coll_dash_image‡   s   
r@   Z
skew_rectsc            	      C   sô   t jdddddd\} }|j}ttjg d¢ddƒ}|d  d	d
g¡ |d  d	d
g¡ |d jddd t	||ƒD ]3\}\}}d| d| }}t
 ¡  ||¡}| d ||¡¡ | tjddgdd||j ddd¡ q:t jdddddd d S )Né   T)é   rB   )ZsharexZshareyZfigsize)éýÿÿÿéÿÿÿÿr   r   é   é   )Úrepeatr   rC   rE   Zequal)Zshareé-   zSkew of {0} in X and {1} in YrD   g      à?Zcoral)r7   Z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   Z	set_titleÚformatZ	add_patchÚmpatchZ	Rectangler5   Zsubplots_adjust)	Zfixr
   Z	rotationsr?   ZxrotsZyrotsZxdegZydegÚtr   r   r   Útest_skew_rectangle“   s   
þrP   )!Ú__doc__Ú
contextlibr   rJ   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patchesrN   Zmatplotlib.projectionsr   ZXTickr   ZXAxisr   r.   r    r%   r@   rP   r   r   r   r   Ú<module>   s(    >
