3
$ßL]Ÿ^ ã               @   sZ  d Z ddlZddlZddl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jZddljZddljZddljZddljZej e!ƒZ"dZ#e	j$ej%ƒZ&e&j'ƒ Z(dd„ e&j)j*ƒ D ƒZ+dd„ e(e+ D ƒZ,G dd	„ d	e	j-ƒZ.G d
d„ de.ƒZ/G dd„ de.ƒZ0G dd„ de1ƒZ2G dd„ de1ƒZ3G dd„ de	j-ƒZ4dd„ Z5G dd„ de4ƒZ6G dd„ de4ƒZ7dS )z)
Classes for the ticks and x and y axis.
é    N)ÚrcParamsé´   c             C   s   g | ]}t |ƒd  ‘qS )r   )Úlist)Ú.0Úd© r   ú7/tmp/pip-install-edjban26/matplotlib/matplotlib/axis.pyú
<listcomp>   s    r	   c             C   s   g | ]}d | ‘qS )Úgrid_r   )r   Únamer   r   r   r	      s   c               @   sl  e Zd ZdZdOdd„Zx\dUD ]T\ZZeej	dedj
eƒd�efdd„ƒej	dedj
eƒd�efdd„ƒƒeƒ e< qW [[eej	dddd�dd„ ƒƒZdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ ZdVd'd(„Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Zejd=d>„ ƒZd?d@„ Z e Z!dAdB„ Z"dCdD„ Z#dEdF„ Z$dGdH„ Z%dIdJ„ Z&dKdL„ Z'dMdN„ Z(dS )WÚTickaˆ  
    Abstract base class for the axis ticks, grid lines and labels.

    Ticks mark a position on an Axis. They contain two lines as markers and
    two labels; one each for the bottom and top positions (in case of an
    `.XAxis`) or for the left and right positions (in case of a `.YAxis`).

    Attributes
    ----------
    tick1line : `.Line2D`
        The left/bottom tick marker.
    tick2line : `.Line2D`
        The right/top tick marker.
    gridline : `.Line2D`
        The grid line associated with the label position.
    label1 : `.Text`
        The left/bottom tick label.
    label2 : `.Text`
        The right/top tick label.

    NTFr   c             K   s€  t jj| ƒ |dkrN|r.td dkr.td }n | rJtd dkrJtd }nd}| j|jƒ || _| jjƒ }|| _	|| _
|dkrœ|r�td|  }ntd	|  }|| _|dkrÈ|r¼td
|  }ntd|  }|| _|dkrâtd|  }|| _|dk�r|�rtd|  }ntd|  }|| _|
dk�r.td|  }
|
| _|	dk�rJtd|  }	|	| _| j|ƒ |dk�r€|�rxtjjd }ntjj}|| _|dk�r˜td n|| _|dk�r°td n|| _|dk�rÈtd n|| _|dk�ràtd n|| _dd„ |jƒ D ƒ| _| j|ƒ | jƒ | _| jƒ | _ | j!ƒ | _"| j#ƒ | _$| j%ƒ | _&| j"j'|ƒ | jj'|ƒ | j j'|ƒ | j$j'|ƒ | j&j'|ƒ | j(|ƒ dS )z¨
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in points
        Nzaxes.grid.whichÚbothÚmajorz	axes.gridÚminorFz%s.major.sizez%s.minor.sizez%s.major.widthz%s.minor.widthz%s.colorz%s.major.padz%s.minor.padz%s.labelsizeg{®Gáz„?z
grid.colorzgrid.linestylezgrid.linewidthz
grid.alphac             S   s   i | ]\}}||d d… “qS )é   Nr   )r   ÚkÚvr   r   r   ú
<dictcomp>š   s    z!Tick.__init__.<locals>.<dictcomp>)r   r   )r   r   ))ÚmartistÚArtistÚ__init__r   Ú
set_figureÚfigureÚaxesÚ__name__ÚlowerÚ_nameÚ_locÚ_sizeÚ_widthÚ_colorÚ	_base_padÚ_labelcolorÚ
_labelsizeÚ_set_labelrotationÚmlinesÚLine2DÚzorderÚ_zorderÚ_grid_colorÚ_grid_linestyleÚ_grid_linewidthÚ_grid_alphaÚitemsÚ_grid_kwÚapply_tickdirÚ_get_tick1lineÚ	tick1lineÚ_get_tick2lineÚ	tick2lineÚ_get_gridlineÚgridlineÚ
_get_text1Úlabel1Ú
_get_text2Úlabel2Úset_visibleÚupdate_position)Úselfr   ÚlocÚlabelÚsizeÚwidthÚcolorÚtickdirÚpadÚ	labelsizeÚ
labelcolorr'   ÚgridOnÚtick1OnÚtick2OnÚlabel1OnÚlabel2Onr   ÚlabelrotationZ
grid_colorZgrid_linestyleZgrid_linewidthZ
grid_alphaÚkwr   r   r   r   r   8   sx    













zTick.__init__rF   r5   rG   r1   rH   r3   rI   r7   rJ   r9   z3.1zTick.{}.get_visible)r   Úalternativec             C   s   t | |ƒjƒ S )N)ÚgetattrÚget_visible)r<   Ú	_new_namer   r   r   Ú<lambda>·   s    zTick.<lambda>zTick.{}.set_visiblec             C   s   t | |ƒj|ƒS )N)rN   r:   )r<   ÚvaluerP   r   r   r   rQ   ½   s    zTick.label1)rM   Úpendingc             C   s   | j S )N)r7   )r<   r   r   r   r>   Á   s    z
Tick.labelc             C   sT   t |tƒr|}d}n t |ttfƒr,|\}}nd}|}tjddg|d� ||f| _d S )Nr   ÚdefaultÚauto)rK   )Ú
isinstanceÚstrÚtupler   ÚcbookÚ_check_in_listÚ_labelrotation)r<   rK   ÚmodeZangler   r   r   r$   Æ   s    

zTick._set_labelrotationc             C   s   dS )z*Calculate self._pad and self._tickmarkers.Nr   )r<   rB   r   r   r   r/   Ò   s    zTick.apply_tickdirc             C   s   | j S )N)Ú_tickdir)r<   r   r   r   Úget_tickdirÕ   s    zTick.get_tickdirc             C   s   ddddœ}| j || j  S )z/Get the length of the tick outside of the axes.g        g      à?g      ð?)ÚinÚinoutÚout)r   r]   )r<   Úpaddingr   r   r   Úget_tick_paddingØ   s    zTick.get_tick_paddingc             C   s   | j | j| j| j| jg}|S )N)r1   r3   r5   r7   r9   )r<   Úchildrenr   r   r   Úget_childrená   s    zTick.get_childrenc             C   s(   t jj| ||ƒ | jj||ƒ d| _d S )NT)r   r   Úset_clip_pathr5   Ústale)r<   ÚclippathÚ	transformr   r   r   rf   æ   s    zTick.set_clip_pathc             C   s   | j j| j d S )NéH   )r   Údpir!   )r<   r   r   r   Úget_pad_pixelsì   s    zTick.get_pad_pixelsc             C   s   | j dk	r| j | |ƒS di fS )zç
        Test whether the mouse event occurred in the Tick marks.

        This function always returns false.  It is more useful to test if the
        axis as a whole contains the mouse rather than the set of tick marks.
        NF)Ú	_contains)r<   Ú
mouseeventr   r   r   Úcontainsï   s    
zTick.containsc             C   s   | j |d� d| _dS )zm
        Set the tick label pad in points

        Parameters
        ----------
        val : float
        )rC   TN)Ú_apply_paramsrg   )r<   Úvalr   r   r   Úset_padú   s    zTick.set_padc             C   s   | j S )z-Get the value of the tick label pad in points)r!   )r<   r   r   r   Úget_pad  s    zTick.get_padc             C   s   dS )zGet the default Text 1 instanceNr   )r<   r   r   r   r6   	  s    zTick._get_text1c             C   s   dS )zGet the default Text 2 instanceNr   )r<   r   r   r   r8     s    zTick._get_text2c             C   s   dS )z)Get the default line2D instance for tick1Nr   )r<   r   r   r   r0     s    zTick._get_tick1linec             C   s   dS )z)Get the default line2D instance for tick2Nr   )r<   r   r   r   r2     s    zTick._get_tick2linec             C   s   dS )z2Get the default grid Line2d instance for this tickNr   )r<   r   r   r   r4     s    zTick._get_gridlinec             C   s   | j S )z2Return the tick location (data coords) as a scalar)r   )r<   r   r   r   Úget_loc  s    zTick.get_locc             C   s`   | j ƒ sd| _d S |j| jƒ x*| j| j| j| j| jgD ]}|j	|ƒ q8W |j
| jƒ d| _d S )NF)rO   rg   Ú
open_groupr   r5   r1   r3   r7   r9   ÚdrawÚclose_group)r<   ÚrendererÚartistr   r   r   rv   !  s    z	Tick.drawc             C   s   | j j|ƒ d| _dS )z]
        Set the label1 text.

        Parameters
        ----------
        s : str
        TN)r7   Úset_textrg   )r<   Úsr   r   r   Ú
set_label1-  s    zTick.set_label1c             C   s   | j j|ƒ d| _dS )z]
        Set the label2 text.

        Parameters
        ----------
        s : str
        TN)r9   rz   rg   )r<   r{   r   r   r   Ú
set_label2:  s    zTick.set_label2c             C   s   |j | jƒ d S )N)r   r   )r<   Úar   r   r   Ú_set_artist_propsE  s    zTick._set_artist_propsc             C   s   t dƒ‚dS )zCreturn the view Interval instance for the axis this tick is tickingzDerived must overrideN)ÚNotImplementedError)r<   r   r   r   Úget_view_intervalH  s    zTick.get_view_intervalc                s|  xPd| j fd| jfd| jfd| jfd| jfgD ] \}}|ˆ kr.|jˆ j|ƒƒ q.W t‡ fdd„dD ƒƒ�r0ˆ jd| jƒ| _ˆ jd	| j	ƒ| _	ˆ jd
| j
ƒ| _
| jˆ jd| jƒƒ | jj| jd ƒ | jj| jd ƒ x,| j| jfD ]}|j| jƒ |j| j	ƒ qàW | jƒ d }| jj|ƒ | jƒ d }| jj|ƒ dd„ ˆ jƒ D ƒ}| jjf |Ž | jjf |Ž x&|jƒ D ]\}}t| d| |ƒ �qhW dˆ k�rÈ| jˆ jdƒƒ | jj| jd d� | jj| jd d� dd„ ˆ jƒ D ƒ}	| jjf |	Ž | jjf |	Ž x8|	jƒ D ],\}}t| jd| ƒƒ }t| d| |ƒ �q W dd„ ˆ jƒ D ƒ}
| j jf |
Ž x&|
jƒ D ]\}}t| d| |ƒ �qZW d S )NrF   rG   rH   rI   rJ   c             3   s   | ]}|ˆ kV  qd S )Nr   )r   r   )rL   r   r   ú	<genexpr>T  s    z%Tick._apply_params.<locals>.<genexpr>r?   r@   rC   rB   r   é   c             S   s   i | ]\}}|dkr||“qS )rA   r'   )rA   r'   r   )r   r   r   r   r   r   r   g  s    z&Tick._apply_params.<locals>.<dictcomp>Ú_rK   )Úrotationc             S   s&   i | ]\}}|dkr||dd… “qS )rD   rE   r   N)rD   rE   r   )r   r   r   r   r   r   r   r  s    Úget_Z_labelc             S   s&   i | ]\}}|t kr||d d… “qS )r   N)Ú_gridline_param_names)r   r   r   r   r   r   r   }  s    Z_grid_)r?   r@   rC   rB   )r5   r1   r3   r7   r9   r:   ÚpopÚanyr   r   r!   r/   r]   Z
set_markerÚ_tickmarkersZset_markersizeZset_markeredgewidthÚ_get_text1_transformÚset_transformÚ_get_text2_transformr-   ÚsetÚsetattrr$   r[   rN   )r<   rL   r   ÚtargetÚlineÚtransÚtick_kwr   r   Zlabel_kwZgrid_kwr   )rL   r   rp   L  sP    

zTick._apply_paramsc             C   s   t dƒ‚dS )z9Set the location of tick in data coords with scalar *loc*zDerived must overrideN)r€   )r<   r=   r   r   r   r;   ƒ  s    zTick.update_positionc             C   s   t dƒ‚d S )NzDerived must override)r€   )r<   r   r   r   r‹   ‡  s    zTick._get_text1_transformc             C   s   t dƒ‚d S )NzDerived must override)r€   )r<   r   r   r   r�   Š  s    zTick._get_text2_transform)NNNNNNNNNTTTFTr   NNNN©rF   r5   ©rG   r1   ©rH   r3   ©rI   r7   ©rJ   r9   )r”   r•   r–   r—   r˜   )N))r   Ú
__module__Ú__qualname__Ú__doc__r   Z	_old_namerP   ÚpropertyrY   Ú
deprecatedÚformatÚlocalsr>   r$   r/   r^   rc   re   rf   rl   ro   rr   rs   r6   r8   r0   r2   r4   rt   r   Úallow_rasterizationrv   r|   Z	set_labelr}   r   r�   rp   r;   r‹   r�   r   r   r   r   r   "   s„                     
`    	
7r   c               @   sd   e Zd ZdZdZ dd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚXTickzq
    Contains all the Artists needed to make an x tick - the tick line,
    the label text and the grid line
    Zxtickc             C   s   | j j| jƒS )N)r   Zget_xaxis_text1_transformÚ_pad)r<   r   r   r   r‹   •  s    zXTick._get_text1_transformc             C   s   | j j| jƒS )N)r   Zget_xaxis_text2_transformr¢   )r<   r   r   r   r�   ˜  s    zXTick._get_text2_transformc             C   sp   |d krt d| j  }|| _| jdkr6tjtjf| _n | jdkrHd| _ntjtjf| _| j| jƒ  | _	d| _
d S )Nz%s.directionr_   r`   ú|T)r£   r£   )r   r   r]   r%   ZTICKUPZTICKDOWNrŠ   r!   rc   r¢   rg   )r<   rB   r   r   r   r/   ›  s    

zXTick.apply_tickdirc             C   sH   | j ƒ \}}}tjddtj| jd�| j||d�}|j|ƒ | j|ƒ |S )zGet the default Text instancer   )r?   )ÚxÚyÚfontpropertiesrA   ÚverticalalignmentÚhorizontalalignment)	r‹   ÚmtextÚTextÚfont_managerÚFontPropertiesr#   r"   rŒ   r   )r<   r’   ÚvertÚhorizÚtr   r   r   r6   ©  s    

zXTick._get_text1c             C   sH   | j ƒ \}}}tjddtj| jd�| j||d�}|j|ƒ | j|ƒ |S )zGet the default Text 2 instancer   rƒ   )r?   )r¤   r¥   r¦   rA   r§   r¨   )	r�   r©   rª   r«   r¬   r#   r"   rŒ   r   )r<   r’   r­   r®   r¯   r   r   r   r8   º  s    

zXTick._get_text2c          
   C   sJ   t jdd| jd| jd | j| j| jd�}|j| jj	dd�ƒ | j
|ƒ |S )zGet the default line2D instancer   ÚNone)ÚxdataÚydatarA   Ú	linestyleÚmarkerÚ
markersizeÚmarkeredgewidthr'   Útick1)Úwhich)r   )r   )r%   r&   r    rŠ   r   r   r(   rŒ   r   Úget_xaxis_transformr   )r<   Úlr   r   r   r0   Ê  s    

zXTick._get_tick1linec          
   C   sJ   t jdd| jd| jd | j| j| jd�}|j| jj	dd�ƒ | j
|ƒ |S )	zGet the default line2D instancer   rƒ   r°   )r±   r²   rA   r³   r´   rµ   r¶   r'   Útick2)r¸   )r   )rƒ   )r%   r&   r    rŠ   r   r   r(   rŒ   r   r¹   r   )r<   rº   r   r   r   r2   Õ  s    

zXTick._get_tick2linec          
   C   sV   t jf dd| j| j| j| jddœ| j—Ž}|j| jj	dd�ƒ t
|jƒ _| j|ƒ |S )	zGet the default line2D instanceç        r   ç      ð?)r±   r²   rA   r³   Ú	linewidthÚalpharµ   Úgrid)r¸   )r¼   r¼   )r   r½   )r%   r&   r)   r*   r+   r,   r.   rŒ   r   r¹   ÚGRIDLINE_INTERPOLATION_STEPSÚget_pathÚ_interpolation_stepsr   )r<   rº   r   r   r   r4   ä  s    



zXTick._get_gridlinec             C   sR   | j j|fƒ | jj|fƒ | jj|fƒ | jj|ƒ | jj|ƒ || _d| _dS )z:Set the location of tick in data coords with scalar *loc*.TN)	r1   Z	set_xdatar3   r5   r7   Zset_xr9   r   rg   )r<   r=   r   r   r   r;   ô  s    zXTick.update_positionc             C   s
   | j jjS )N)r   ÚviewLimÚ	intervalx)r<   r   r   r   r�   þ  s    zXTick.get_view_intervalN)r   r™   rš   r›   r‹   r�   r/   r6   r8   r0   r2   r4   r;   r�   r   r   r   r   r¡   Ž  s   
r¡   c               @   sd   e Zd ZdZdZ dd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚYTickzp
    Contains all the Artists needed to make a Y tick - the tick line,
    the label text and the grid line
    Zytickc             C   s   | j j| jƒS )N)r   Zget_yaxis_text1_transformr¢   )r<   r   r   r   r‹   
  s    zYTick._get_text1_transformc             C   s   | j j| jƒS )N)r   Zget_yaxis_text2_transformr¢   )r<   r   r   r   r�     s    zYTick._get_text2_transformc             C   sp   |d krt d| j  }|| _| jdkr6tjtjf| _n | jdkrHd| _ntjtjf| _| j| jƒ  | _	d| _
d S )Nz%s.directionr_   r`   r„   T)r„   r„   )r   r   r]   r%   Z	TICKRIGHTZTICKLEFTrŠ   r!   rc   r¢   rg   )r<   rB   r   r   r   r/     s    

zYTick.apply_tickdirc             C   sH   | j ƒ \}}}tjddtj| jd�| j||d�}|j|ƒ | j|ƒ |S )zGet the default Text instancer   )r?   )r¤   r¥   r¦   rA   r§   r¨   )	r‹   r©   rª   r«   r¬   r#   r"   rŒ   r   )r<   r’   r­   r®   r¯   r   r   r   r6     s    

zYTick._get_text1c             C   sH   | j ƒ \}}}tjddtj| jd�| j||d�}|j|ƒ | j|ƒ |S )zGet the default Text instancerƒ   r   )r?   )r¤   r¥   r¦   rA   r§   r¨   )	r�   r©   rª   r«   r¬   r#   r"   rŒ   r   )r<   r’   r­   r®   r¯   r   r   r   r8   .  s    

zYTick._get_text2c          
   C   sJ   t jdd| j| jd d| j| j| jd�}|j| jj	dd�ƒ | j
|ƒ |S )zGet the default line2D instancer   r°   )rA   r´   r³   rµ   r¶   r'   r·   )r¸   )r   )r   )r%   r&   r    rŠ   r   r   r(   rŒ   r   Úget_yaxis_transformr   )r<   rº   r   r   r   r0   =  s    

zYTick._get_tick1linec          
   C   sJ   t jdd| j| jd d| j| j| jd�}|j| jj	dd�ƒ | j
|ƒ |S )	zGet the default line2D instancerƒ   r   r°   )rA   r´   r³   rµ   r¶   r'   r»   )r¸   )rƒ   )r   )r%   r&   r    rŠ   r   r   r(   rŒ   r   rÇ   r   )r<   rº   r   r   r   r2   L  s    

zYTick._get_tick2linec          
   C   sV   t jf dd| j| j| j| jddœ| j—Ž}|j| jj	dd�ƒ t
|jƒ _| j|ƒ |S )zGet the default line2D instancer   rƒ   )r±   r²   rA   r³   r¾   r¿   rµ   rÀ   )r¸   )r   rƒ   )r   r   )r%   r&   r)   r*   r+   r,   r.   rŒ   r   rÇ   rÁ   rÂ   rÃ   r   )r<   rº   r   r   r   r4   Z  s    



zYTick._get_gridlinec             C   sR   | j j|fƒ | jj|fƒ | jj|fƒ | jj|ƒ | jj|ƒ || _d| _dS )z:Set the location of tick in data coords with scalar *loc*.TN)	r1   Z	set_ydatar3   r5   r7   Zset_yr9   r   rg   )r<   r=   r   r   r   r;   i  s    zYTick.update_positionc             C   s
   | j jjS )z7Return the Interval instance for this axis view limits.)r   rÄ   Ú	intervaly)r<   r   r   r   r�   s  s    zYTick.get_view_intervalN)r   r™   rš   r›   r‹   r�   r/   r6   r8   r0   r2   r4   r;   r�   r   r   r   r   rÆ     s   
rÆ   c               @   s   e Zd ZdZdZdZdS )ÚTickera2  
    A container for the objects defining tick position and format.

    Attributes
    ----------
    locator : `matplotlib.ticker.Locator` subclass
        Determines the positions of the ticks.
    formatter : `matplotlib.ticker.Formatter` subclass
        Determines the format of the tick labels.
    N)r   r™   rš   r›   ÚlocatorÚ	formatterr   r   r   r   rÉ   x  s   
rÉ   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú_LazyTickListz—
    A descriptor for lazy instantiation of tick lists.

    See comment above definition of the ``majorTicks`` and ``minorTicks``
    attributes.
    c             C   s
   || _ d S )N)Ú_major)r<   r   r   r   r   r   �  s    z_LazyTickList.__init__c             C   s^   |d kr| S | j r6g |_|jdd�}|jj|ƒ |jS g |_|jdd�}|jj|ƒ |jS d S )NT)r   F)rÍ   Ú
majorTicksÚ	_get_tickÚappendÚ
minorTicks)r<   ÚinstanceÚclsÚtickr   r   r   Ú__get__’  s    z_LazyTickList.__get__N)r   r™   rš   r›   r   rÕ   r   r   r   r   rÌ   ‡  s   rÌ   c               @   s  e Zd ZdZdZdd„ Zd³dd„Zedd	�Zed
d	�Z	dd„ Z
dd„ Zee
edd�Zd´dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zdµd#d$„Zed%d&„ ƒZd¶d'd(„Zd)d*„ Zd·d+d,„Zd-d.„ Zd¸d/d0„Zd1d2„ Zd3d4„ Zd5d6„ Z d7d8„ Z!e"j#d9ƒd:d;„ ƒZ$d<d=„ Z%d>d?„ Z&d@dA„ Z'dBdC„ Z(dDdE„ Z)dFdG„ Z*dHdI„ Z+e,j-dJdK„ ƒZ.dLdM„ Z/dNdO„ Z0dPdQ„ Z1dRdS„ Z2dTdU„ Z3dVdW„ Z4dXdY„ Z5dZd[„ Z6d¹d\d]„Z7d^d_„ Z8d`da„ Z9dºdbdc„Z:ddde„ Z;dfdg„ Z<d»dhdi„Z=d¼djdk„Z>dldm„ Z?dndo„ Z@dpdq„ ZAdrds„ ZBdtdu„ ZCdvdw„ ZDdxdy„ ZEd½dzd{„ZFd¾d|d}„ZGd¿d~d„ZHd€d�„ ZId‚dƒ„ ZJd„d…„ ZKd†d‡„ ZLdˆd‰„ ZMdŠd‹„ ZNdÀdŒd�„ZOdŽd�„ ZPd�d‘„ ZQd’d“„ ZRd”d•„ ZSd–d—„ ZTd
d˜œd™dš„ZUdÁd›dœ„ZVd�dž„ ZWdŸd „ ZXd¡d¢„ ZYd£d¤„ ZZd¥d¦„ Z[dÂd§d¨„Z\d©dª„ Z]d«d¬„ Z^d­d®„ Z_d¯d°„ Z`d±d²„ ZadS )ÃÚAxisa¶  
    Base class for `.XAxis` and `.YAxis`.

    Attributes
    ----------
    isDefault_label : bool

    axes : `matplotlib.axes.Axes`
        The `~.axes.Axes` to which the Axis belongs.
    major : `matplotlib.axis.Ticker`
        Determines the major tick positions and their label format.
    minor : `matplotlib.axis.Ticker`
        Determines the minor tick positions and their label format.
    callbacks : `matplotlib.cbook.CallbackRegistry`

    label : `.Text`
        The axis label.
    labelpad : float
        The distance between the axis label and the tick labels.
        Defaults to :rc:`axes.labelpad` = 4.
    offsetText : `.Text`
        A `.Text` object containing the data offset of the ticks (if any).
    pickradius : float
        The acceptance radius for containment tests. See also `.Axis.contains`.
    majorTicks : list of `.Tick`
        The major ticks.
    minorTicks : list of `.Tick`
        The minor ticks.
    é   c             C   s   | j jdt| jjjdƒƒ  S )Nz(%f,%f)r   )r   r   )Ú	__class__r   rX   r   Ú	transAxesÚtransform_point)r<   r   r   r   Ú__str__Ç  s    zAxis.__str__é   c             C   sš   t jj| ƒ d| _| j|jƒ d| _|| _tƒ | _	tƒ | _
tjƒ | _d| _d| _| jƒ | _td | _| jƒ | _|| _tƒ | _tƒ | _| jƒ  | jdƒ dS )a  
        Parameters
        ----------
        axes : `matplotlib.axes.Axes`
            The `~.axes.Axes` to which the created Axis belongs.
        pickradius : float
            The acceptance radius for containment tests. See also
            `.Axis.contains`.
        TFzaxes.labelpadÚlinearN)r   r   r   Ú_remove_overlapping_locsr   r   ÚisDefault_labelr   rÉ   r   r   rY   ÚCallbackRegistryÚ	callbacksÚ_autolabelposÚ_smart_boundsÚ
_get_labelr>   r   ÚlabelpadÚ_get_offset_textÚ
offsetTextÚ
pickradiusÚdictÚ_major_tick_kwÚ_minor_tick_kwÚclaÚ
_set_scale)r<   r   rè   r   r   r   r   Ë  s$    




zAxis.__init__T)r   Fc             C   s   | j S )N)rÞ   )r<   r   r   r   Úget_remove_overlapping_locs÷  s    z Axis.get_remove_overlapping_locsc             C   s   t |ƒ| _d S )N)ÚboolrÞ   )r<   rq   r   r   r   Úset_remove_overlapping_locsú  s    z Axis.set_remove_overlapping_locszUIf minor ticker locations that overlap with major ticker locations should be trimmed.)ÚdocNc             C   s<   d| _ |dkr| jj}| jj|ƒ | jj||fƒ d| _dS )a  
        Set the coordinates of the label.

        By default, the x coordinate of the y label is determined by the tick
        label bounding boxes, but this can lead to poor alignment of multiple
        ylabels if there are multiple axes.  Ditto for the y coordinate of
        the x label.

        You can also specify the coordinate system of the label with
        the transform.  If None, the default coordinate system will be
        the axes coordinate system (0,0) is (left,bottom), (0.5, 0.5)
        is middle, etc
        FNT)râ   r   rÙ   r>   rŒ   Úset_positionrg   )r<   r¤   r¥   ri   r   r   r   Úset_label_coords  s    zAxis.set_label_coordsc             C   s
   | j jƒ S )N)Ú_scaleÚget_transform)r<   r   r   r   rõ     s    zAxis.get_transformc             C   s   | j jS )N)rô   r   )r<   r   r   r   Ú	get_scale  s    zAxis.get_scalec             K   s:   t j|| f|Ž| _| jj| ƒ d| _d| _d| _d| _d S )NT)ÚmscaleZscale_factoryrô   Z#set_default_locators_and_formattersÚisDefault_majlocÚisDefault_minlocÚisDefault_majfmtÚisDefault_minfmt)r<   rR   Úkwargsr   r   r   rí     s    zAxis._set_scalec             C   s   | j j||| jƒ ƒS )N)rô   Úlimit_range_for_scaleÚ
get_minpos)r<   ÚvminÚvmaxr   r   r   rý   '  s    zAxis.limit_range_for_scalec             C   s4   | j | jg}| jƒ }| jƒ }|j|ƒ |j|ƒ |S )N)r>   rç   Úget_major_ticksÚget_minor_ticksÚextend)r<   rd   Z
majorticksZ
minorticksr   r   r   re   *  s    

zAxis.get_childrenc             C   st   | j jdƒ | jdƒ tjƒ | _td o2td d
k| _td oHtd dk| _| j	ƒ  d| _
d| _| jdƒ d	| _dS )zclear the current axisÚ rÝ   z	axes.gridzaxes.grid.whichr   r   r   NT)r   r   )r   r   )r>   rz   rí   rY   rà   rá   r   Ú_gridOnMajorÚ_gridOnMinorÚreset_ticksÚ	converterÚunitsÚ	set_unitsrg   )r<   r   r   r   rì   3  s    


zAxis.clac             C   sh   y| ` W n tk
r   Y nX y| `W n tk
r:   Y nX y| j| jjƒ W n tk
rb   Y nX dS )zs
        Re-initialize the major and minor Tick lists.

        Each list starts with a single fresh Tick.
        N)rÎ   ÚAttributeErrorrÑ   rf   r   Úpatch)r<   r   r   r   r  J  s    zAxis.reset_ticksr   c             K   sò   g }|dks|dkr |j | jƒ |dks0|dkr<|j | jƒ | j|ƒ}x"|D ]}|r\|jƒ  |j|ƒ qLW |rx| jƒ  np|dksˆ|dkr¤x| jD ]}|jf |Ž q�W |dks´|dkrÐx| j	D ]}|jf |Ž q¼W d|krè| j
j|d ƒ d| _dS )z¸
        Set appearance parameters for ticks, ticklabels, and gridlines.

        For documentation of keyword arguments, see
        :meth:`matplotlib.axes.Axes.tick_params`.
        r   r   r   rE   TN)rÐ   rê   rë   Ú_translate_tick_kwÚclearÚupdater  rÎ   rp   rÑ   rç   Z	set_colorrg   )r<   r¸   ÚresetrL   ZdictsÚkwtransr   rÔ   r   r   r   Úset_tick_params^  s*    


zAxis.set_tick_paramsc             C   s�  ddddddddd	d
ddddddddddddddgt  }i }d| krR| jdƒ|d< d| krh| jdƒ|d< d| kr~| jdƒ|d< d| kr”| jdƒ|d
< d| krª| jdƒ|d
< d| krÀ| jdƒ|d< d| krÖ| jdƒ|d< d| krì| jdƒ|d< d| k�r| jdƒ|d< d| k�r| jdƒ|d< d| k�r4| jdƒ|d< d| k�rX| jdƒ}||d< ||d< x2| D ]*}||k�r|td||f ƒ‚|j| ƒ �q^W |S )Nr?   r@   rA   rB   rC   rD   rE   r'   rF   rG   rH   rI   rJ   ÚlengthÚ	directionÚleftÚbottomÚrightÚtopÚ	labelleftÚlabelbottomÚ
labelrightÚlabeltoprK   r…   Úcolorsz3keyword %s is not recognized; valid keywords are %s)r‡   rˆ   Ú
ValueErrorr  )rL   Zkwkeysr  ÚcÚkeyr   r   r   r  „  sP    








zAxis._translate_tick_kwc             C   s<   t jj| ||ƒ x | j| j D ]}|j||ƒ qW d| _d S )NT)r   r   rf   rÎ   rÑ   rg   )r<   rh   ri   Úchildr   r   r   rf   ±  s    zAxis.set_clip_pathc             C   s   t dƒ‚dS )z7Return the Interval instance for this axis view limits.zDerived must overrideN)r€   )r<   r   r   r   r�   ·  s    zAxis.get_view_intervalc             C   s   t dƒ‚dS )a6  
        Set the axis view limits.  This method is for internal use; Matplotlib
        users should typically use e.g. `~Axes.set_xlim` and `~Axes.set_ylim`.

        If *ignore* is False (the default), this method will never reduce the
        preexisting view limits, only expand them if *vmin* or *vmax* are not
        within them.  Moreover, the order of *vmin* and *vmax* does not matter;
        the orientation of the axis will not change.

        If *ignore* is True, the view limits will be set exactly to ``(vmin,
        vmax)`` in that order.
        zDerived must overrideN)r€   )r<   rÿ   r   Úignorer   r   r   Úset_view_interval»  s    zAxis.set_view_intervalc             C   s   t dƒ‚dS )z7Return the Interval instance for this axis data limits.zDerived must overrideN)r€   )r<   r   r   r   Úget_data_intervalÊ  s    zAxis.get_data_intervalc             C   s   t dƒ‚dS )aÜ  
        Set the axis data limits.  This method is for internal use.

        If *ignore* is False (the default), this method will never reduce the
        preexisting data limits, only expand them if *vmin* or *vmax* are not
        within them.  Moreover, the order of *vmin* and *vmax* does not matter;
        the orientation of the axis will not change.

        If *ignore* is True, the data limits will be set exactly to ``(vmin,
        vmax)`` in that order.
        zDerived must overrideN)r€   )r<   rÿ   r   r"  r   r   r   Úset_data_intervalÎ  s    zAxis.set_data_intervalc             C   s   | j ƒ \}}||k S )a-  
        Return whether the axis is oriented in the "inverse" direction.

        The "normal" direction is increasing to the right for the x-axis and to
        the top for the y-axis; the "inverse" direction is increasing to the
        left for the x-axis and to the bottom for the y-axis.
        )r�   )r<   ÚlowÚhighr   r   r   Úget_invertedÜ  s    zAxis.get_invertedc             C   s   t dƒ‚dS )a*  
        Set whether the axis is oriented in the "inverse" direction.

        The "normal" direction is increasing to the right for the x-axis and to
        the top for the y-axis; the "inverse" direction is increasing to the
        left for the x-axis and to the bottom for the y-axis.
        zDerived must overrideN)r€   )r<   Úinvertedr   r   r   Úset_invertedç  s    zAxis.set_invertedc             C   s   dS )z{
        Set the default limits for the axis data and view interval if they
        have not been not mutated yet.
        Nr   )r<   r   r   r   Úset_default_intervalsô  s    zAxis.set_default_intervalsc             C   s   |d krd S |j | jƒ d S )N)r   r   )r<   r~   r   r   r   r     s    zAxis._set_artist_propsz3.1c             c   sp   | j ƒ }| jjj|ƒ}| jt|ƒƒ}t|||ƒE dH  | jƒ }| jjj|ƒ}| j	t|ƒƒ}t|||ƒE dH  dS )zU
        Yield ``(Tick, location, label)`` tuples for major and minor ticks.
        N)
Úget_majorticklocsr   rË   Úformat_ticksr  ÚlenÚzipÚget_minorticklocsr   r  )r<   Ú
major_locsÚmajor_labelsÚmajor_ticksÚ
minor_locsÚminor_labelsÚminor_ticksr   r   r   Ú
iter_ticks  s    zAxis.iter_ticksc             C   sp   | j ƒ }| j||ƒ\}}t|ƒr.tjj|ƒ}ntjjddddƒ}t|ƒrVtjj|ƒ}ntjjddddƒ}||fS )zX
        Get the extents of the tick labels on either side
        of the axes.
        r   )Ú_update_ticksÚ_get_tick_bboxesr.  ÚmtransformsÚBboxÚunionZfrom_extents)r<   rx   Úticks_to_drawÚticklabelBoxesÚticklabelBoxes2ÚbboxÚbbox2r   r   r   Úget_ticklabel_extents  s    
zAxis.get_ticklabel_extentsc             C   s   || _ d| _dS )z"Set the axis to have smart bounds.TN)rã   rg   )r<   rR   r   r   r   Úset_smart_bounds)  s    zAxis.set_smart_boundsc             C   s   | j S )z)Return whether the axis has smart bounds.)rã   )r<   r   r   r   Úget_smart_bounds.  s    zAxis.get_smart_boundsc                s&  | j ƒ }| jjj|ƒ}| jt|ƒƒ}| jjj|ƒ x8t|||ƒD ](\}}}|j|ƒ |j	|ƒ |j
|ƒ q@W | jƒ }| jjj|ƒ}| jt|ƒƒ}	| jjj|ƒ x8t|	||ƒD ](\}}}|j|ƒ |j	|ƒ |j
|ƒ q¬W ||	•}
| jƒ \}}||k�r || }}| j�r¶|
�r¶t| jƒ ƒ\}}tjdd„ |
D ƒƒ}||k�rB|‰n(|||k }t|ƒ�rb|d ‰n|d ‰||k�rz|‰ n(|||k }t|ƒ�rš|d ‰ n|d ‰ ‡ ‡fdd„|
D ƒ}
| jƒ j||gƒ}g }xT|
D ]L}y| jƒ j|jƒ ƒ}W n tk
�r   Y nX tj||ƒ�rÒ|j|ƒ �qÒW |S )z—
        Update ticks (position and labels) using the current data interval of
        the axes.  Return the list of ticks that will be drawn.
        c             S   s   g | ]}|j ƒ ‘qS r   )rt   )r   rÔ   r   r   r   r	   P  s    z&Axis._update_ticks.<locals>.<listcomp>rƒ   r   c                s,   g | ]$}ˆ|j ƒ   koˆ kn  r|‘qS r   )rt   )r   rÔ   )ÚihighÚilowr   r   r	   i  s    éÿÿÿÿrG  )r,  r   rË   r-  r  r.  Zset_locsr/  r;   r|   r}   r0  r   r  r�   rã   Úsortedr$  ÚnpÚsortrõ   ri   rt   ÚAssertionErrorr:  Z_interval_contains_closerÐ   )r<   r1  r2  r3  rÔ   r=   r>   r4  r5  r6  ÚticksZview_lowZ	view_highZdata_lowZ	data_highZlocsZ	good_locsZ
interval_tr=  Zloc_tr   )rE  rF  r   r8  2  s\    












zAxis._update_ticksc                s$   ‡ fdd„|D ƒ‡ fdd„|D ƒfS )z8Return lists of bboxes for ticks' label1's and label2's.c                s"   g | ]}|j jƒ r|j jˆ ƒ‘qS r   )r7   rO   Úget_window_extent)r   rÔ   )rx   r   r   r	   }  s   z)Axis._get_tick_bboxes.<locals>.<listcomp>c                s"   g | ]}|j jƒ r|j jˆ ƒ‘qS r   )r9   rO   rM  )r   rÔ   )rx   r   r   r	     s   r   )r<   rL  rx   r   )rx   r   r9  {  s    

zAxis._get_tick_bboxesc                s”   | j ƒ sdS | jƒ }| jˆ ƒ | j|ˆ ƒ\}}| j||ƒ | jj| jjj	ƒ ƒ ‡ fdd„| j
| jgD ƒ||•}dd„ |D ƒ}|rŒtjj|ƒS dS dS )z�
        Return a bounding box that encloses the axis. It only accounts
        tick labels, axis label, and offsetText.
        Nc             3   s    | ]}|j ƒ r|jˆ ƒV  qd S )N)rO   rM  )r   r~   )rx   r   r   r‚   –  s   z%Axis.get_tightbbox.<locals>.<genexpr>c             S   sH   g | ]@}d |j   k otjk n  rd |j  k o:tjk n  r|‘qS )r   )r@   rI  ÚinfÚheight)r   Úbr   r   r   r	   œ  s    z&Axis.get_tightbbox.<locals>.<listcomp>)rO   r8  Ú_update_label_positionr9  Ú_update_offset_text_positionrç   rz   r   rË   Ú
get_offsetr>   r:  r;  r<  )r<   rx   r=  r>  r?  Úbboxesr   )rx   r   Úget_tightbbox‚  s     

zAxis.get_tightbboxc             C   sL   g }t | jƒr"|j| jd jƒ ƒ t | jƒr@|j| jd jƒ ƒ t|dd�S )Nr   )rT   )r.  rÎ   rÐ   rc   rÑ   Úmax)r<   Úvaluesr   r   r   rc   £  s    

zAxis.get_tick_paddingc             O   sœ   | j ƒ sdS |jtƒ | jƒ }| j||ƒ\}}x|D ]}|j|ƒ q4W | j|ƒ | jj|ƒ | j||ƒ | j	j
| jjjƒ ƒ | j	j|ƒ |jtƒ d| _dS )z6Draw the axis lines, grid lines, tick lines and labelsNF)rO   ru   r   r8  r9  rv   rQ  r>   rR  rç   rz   r   rË   rS  rw   rg   )r<   rx   Úargsrü   r=  r>  r?  rÔ   r   r   r   rv   «  s    




z	Axis.drawc             C   s   t dƒ‚d S )NzDerived must override)r€   )r<   r   r   r   rä   Ê  s    zAxis._get_labelc             C   s   t dƒ‚d S )NzDerived must override)r€   )r<   r   r   r   ræ   Í  s    zAxis._get_offset_textc             C   s   | j ƒ }tjddd„ |D ƒƒS )z2Return the grid lines as a list of Line2D instancezLine2D gridlinec             S   s   g | ]
}|j ‘qS r   )r5   )r   rÔ   r   r   r   r	   Ô  s    z&Axis.get_gridlines.<locals>.<listcomp>)r  rY   Úsilent_list)r<   rL  r   r   r   Úget_gridlinesÐ  s    zAxis.get_gridlinesc             C   s   | j S )z(Return the axis label as a Text instance)r>   )r<   r   r   r   Ú	get_labelÖ  s    zAxis.get_labelc             C   s   | j S )z-Return the axis offsetText as a Text instance)rç   )r<   r   r   r   Úget_offset_textÚ  s    zAxis.get_offset_textc             C   s   | j S )z/Return the depth of the axis used by the picker)rè   )r<   r   r   r   Úget_pickradiusÞ  s    zAxis.get_pickradiusc             C   s4   | j ƒ }dd„ |D ƒ}dd„ |D ƒ}tjd|| ƒS )z9Return a list of Text instances for the major ticklabels.c             S   s   g | ]}|j jƒ r|j ‘qS r   )r7   rO   )r   rÔ   r   r   r   r	   å  s    z,Axis.get_majorticklabels.<locals>.<listcomp>c             S   s   g | ]}|j jƒ r|j ‘qS r   )r9   rO   )r   rÔ   r   r   r   r	   æ  s    zText major ticklabel)r  rY   rY  )r<   rL  Úlabels1Úlabels2r   r   r   Úget_majorticklabelsâ  s    zAxis.get_majorticklabelsc             C   s4   | j ƒ }dd„ |D ƒ}dd„ |D ƒ}tjd|| ƒS )z9Return a list of Text instances for the minor ticklabels.c             S   s   g | ]}|j jƒ r|j ‘qS r   )r7   rO   )r   rÔ   r   r   r   r	   ì  s    z,Axis.get_minorticklabels.<locals>.<listcomp>c             S   s   g | ]}|j jƒ r|j ‘qS r   )r9   rO   )r   rÔ   r   r   r   r	   í  s    zText minor ticklabel)r  rY   rY  )r<   rL  r^  r_  r   r   r   Úget_minorticklabelsé  s    zAxis.get_minorticklabelsc             C   sh   |dk	rT|dkr| j ƒ S |dkr(| jƒ S |dkr@| jƒ | j ƒ  S tjdddg|d� |r`| j ƒ S | jƒ S )aÖ  
        Get the tick labels as a list of `~matplotlib.text.Text` instances.

        Parameters
        ----------
        minor : bool
           If True return the minor ticklabels,
           else return the major ticklabels

        which : None, ('minor', 'major', 'both')
           Overrides `minor`.

           Selects which ticklabels to return

        Returns
        -------
        ret : list
           List of `~matplotlib.text.Text` instances.
        Nr   r   r   )r¸   )ra  r`  rY   rZ   )r<   r   r¸   r   r   r   Úget_ticklabelsð  s    zAxis.get_ticklabelsc             C   s>   g }| j ƒ }x$|D ]}|j|jƒ |j|jƒ qW tjd|ƒS )z9Return the major tick lines as a list of Line2D instanceszLine2D ticklines)r  rÐ   r1   r3   rY   rY  )r<   ÚlinesrL  rÔ   r   r   r   Úget_majorticklines  s    
zAxis.get_majorticklinesc             C   s>   g }| j ƒ }x$|D ]}|j|jƒ |j|jƒ qW tjd|ƒS )z9Return the minor tick lines as a list of Line2D instanceszLine2D ticklines)r  rÐ   r1   r3   rY   rY  )r<   rc  rL  rÔ   r   r   r   Úget_minorticklines  s    
zAxis.get_minorticklinesc             C   s   |r| j ƒ S | jƒ S )z3Return the tick lines as a list of Line2D instances)re  rd  )r<   r   r   r   r   Úget_ticklines$  s    zAxis.get_ticklinesc             C   s
   | j jƒ S )z:Get the array of major tick locations in data coordinates.)r   rÊ   )r<   r   r   r   r,  *  s    zAxis.get_majorticklocsc                sx   | j jƒ }| jjƒ }| jjƒ }|j|ƒ}|j|ƒ‰t|j| jƒ ƒƒ\}}|| d ‰ | jrt‡ ‡fdd„t	||ƒD ƒ}|S )z:Get the array of minor tick locations in data coordinates.gñhãˆµøä>c                s,   g | ]$\}}t j|ˆˆ d d�jƒ  r|‘qS )r   )ZatolZrtol)rI  Úiscloser‰   )r   r=   Ztr_loc)ÚtolÚtr_major_locsr   r   r	   <  s    z*Axis.get_minorticklocs.<locals>.<listcomp>)
r   rÊ   r   rô   rõ   ri   rH  r�   Úremove_overlapping_locsr/  )r<   r1  r4  ri   Ztr_minor_locsÚloÚhir   )rh  ri  r   r0  .  s    




zAxis.get_minorticklocsc             C   s   |r| j ƒ S | jƒ S )z4Get the array of tick locations in data coordinates.)r0  r,  )r<   r   r   r   r   Úget_ticklocs@  s    zAxis.get_ticklocsc             C   s8   |rt jdd„ | jƒ D ƒƒS t jdd„ | jƒ D ƒƒS dS )aK  
        Get the tick directions as a numpy array

        Parameters
        ----------
        minor : boolean
            True to return the minor tick directions,
            False to return the major tick directions,
            Default is False

        Returns
        -------
        numpy array of tick directions
        c             S   s   g | ]
}|j ‘qS r   )r]   )r   rÔ   r   r   r   r	   U  s    z,Axis.get_ticks_direction.<locals>.<listcomp>c             S   s   g | ]
}|j ‘qS r   )r]   )r   rÔ   r   r   r   r	   X  s    N)rI  Úarrayr  r  )r<   r   r   r   r   Úget_ticks_directionD  s
    zAxis.get_ticks_directionc             C   s   t dƒ‚dS )z return the default tick instancezderived must overrideN)r€   )r<   r   r   r   r   rÏ   Z  s    zAxis._get_tickc             C   s^   |dks|dkrdS |j j|j ƒ |jj|jƒ |jj|jƒ |jj|jƒ |jj|jƒ dS )z)Copy the props from src tick to dest tickN)r7   Zupdate_fromr9   r1   r3   r5   )r<   ÚsrcÚdestr   r   r   Ú_copy_tick_props^  s    zAxis._copy_tick_propsc             C   s
   | j jƒ S )zGet the text of the label)r>   Úget_text)r<   r   r   r   Úget_label_texth  s    zAxis.get_label_textc             C   s   | j jS )z#Get the locator of the major ticker)r   rÊ   )r<   r   r   r   Úget_major_locatorl  s    zAxis.get_major_locatorc             C   s   | j jS )z#Get the locator of the minor ticker)r   rÊ   )r<   r   r   r   Úget_minor_locatorp  s    zAxis.get_minor_locatorc             C   s   | j jS )z%Get the formatter of the major ticker)r   rË   )r<   r   r   r   Úget_major_formattert  s    zAxis.get_major_formatterc             C   s   | j jS )z%Get the formatter of the minor ticker)r   rË   )r<   r   r   r   Úget_minor_formatterx  s    zAxis.get_minor_formatterc             C   sn   |dkrt | jƒ ƒ}xJt | jƒ|k r^| jdd�}| jj|ƒ |jj| jƒ | j| jd |ƒ qW | jd|… S )z*Get the tick instances; grow as necessary.NT)r   r   )	r.  r,  rÎ   rÏ   rÐ   r5   r:   r  rr  )r<   ÚnumticksrÔ   r   r   r   r  |  s    zAxis.get_major_ticksc             C   sn   |dkrt | jƒ ƒ}xJt | jƒ|k r^| jdd�}| jj|ƒ |jj| jƒ | j| jd |ƒ qW | jd|… S )z0Get the minor tick instances; grow as necessary.NF)r   r   )	r.  r0  rÑ   rÏ   rÐ   r5   r:   r  rr  )r<   ry  rÔ   r   r   r   r  Š  s    zAxis.get_minor_ticksc             K   sÐ   t |ƒr$| r |dk	r tjdƒ d}|jƒ }tjdddg|d� dd	„ |jƒ D ƒ}|dkrŒ|dkrn| j | _n|| _| jf d| jd
œ|—Ž |dkrÆ|dkr¨| j | _n|| _| jf d| jd
œ|—Ž d| _	dS )ar  
        Configure the grid lines.

        Parameters
        ----------
        b : bool or None
            Whether to show the grid lines. If any *kwargs* are supplied,
            it is assumed you want the grid on and *b* will be set to True.

            If *b* is *None* and there are no *kwargs*, this toggles the
            visibility of the lines.

        which : {'major', 'minor', 'both'}
            The grid lines to apply the changes on.

        **kwargs : `.Line2D` properties
            Define the line properties of the grid, e.g.::

                grid(color='r', linestyle='-', linewidth=2)

        Nz_First parameter to grid() is false, but line properties are supplied. The grid will be enabled.Tr   r   r   )r¸   c             S   s   i | ]}|d  d|d  “qS )rƒ   r
   r   r   )r   Úitemr   r   r   r   ¶  s    zAxis.grid.<locals>.<dictcomp>)r¸   rF   )r   r   )r   r   )
r.  rY   Z_warn_externalr   rZ   r-   r  r  r  rg   )r<   rP  r¸   rü   Zgridkwr   r   r   rÀ   ˜  s(    
z	Axis.gridc             C   sh   t jj|ƒ}|dkrdS | j|k}|| _| jj|| ƒ}|dk	rR| jdkrR| j|ƒ |r^| jƒ  d| _dS )z·
        introspect *data* for units converter and update the
        axis.converter instance if necessary. Return *True*
        if *data* is registered for unit conversion.
        NFT)	ÚmunitsÚregistryÚget_converterr  Zdefault_unitsr	  r
  Ú_update_axisinforg   )r<   Údatar  ZneednewrT   r   r   r   Úupdate_unitsÈ  s    

zAxis.update_unitsc             C   s  | j dkrdS | j j| j| ƒ}|dkr*dS |jdk	rZ| jj|jkrZ| jrZ| j|jƒ d| _|jdk	rŠ| j	j|jkrŠ| j
rŠ| j|jƒ d| _
|jdk	rº| jj|jkrº| jrº| j|jƒ d| _|jdk	rê| j	j|jkrê| jrê| j|jƒ d| _|jdk	oø| j�r| j|jƒ d| _| jƒ  dS )zs
        check the axis converter for the stored units to see if the
        axis info needs to be updated
        NT)r  Úaxisinfor	  Zmajlocr   rÊ   rø   Úset_major_locatorZminlocr   rù   Úset_minor_locatorZmajfmtrË   rú   Úset_major_formatterZminfmtrû   Úset_minor_formatterr>   rß   Úset_label_textr+  )r<   Úinfor   r   r   r~  Þ  s2    




zAxis._update_axisinfoc             C   s   | j d k	p| jd k	S )N)r  r	  )r<   r   r   r   Ú
have_units   s    zAxis.have_unitsc             C   s†   t jj|ƒr|S | jd kr(t jj|ƒ| _| jd kr6|S y| jj|| j| ƒ}W n4 tk
r€ } zt j	d|›�ƒ|‚W Y d d }~X nX |S )Nz*Failed to convert value(s) to axis units: )
r{  ZConversionInterfaceZ
is_numliker  r|  r}  Úconvertr	  Ú	ExceptionZConversionError)r<   r¤   ÚretÚer   r   r   Úconvert_units  s    

zAxis.convert_unitsc             C   sZ   d}|dkrd| _ d}n|| j kr,|| _ d}|rP| jƒ  | jjdƒ | jjdƒ d| _dS )zf
        Set the units for axis.

        Parameters
        ----------
        u : units tag
        FNTr	  zunits finalize)r	  r~  rá   Úprocessrg   )r<   ÚuZpchangedr   r   r   r
    s    
zAxis.set_unitsc             C   s   | j S )zReturn the units for axis.)r	  )r<   r   r   r   Ú	get_units*  s    zAxis.get_unitsc             K   s>   d| _ | jj|ƒ |dk	r&| jj|ƒ | jj|ƒ d| _| jS )zó
        Set the text value of the axis label.

        Parameters
        ----------
        label : str
            Text string.
        fontdict : dict
            Text properties.
        **kwargs
            Merged into fontdict.
        FNT)rß   r>   rz   r  rg   )r<   r>   Zfontdictrü   r   r   r   r†  .  s    zAxis.set_label_textc             C   s6   t |tjƒstdƒ‚d| _|| j_|j| ƒ d| _dS )z’
        Set the formatter of the major ticker.

        Parameters
        ----------
        formatter : `~matplotlib.ticker.Formatter`
        zDformatter argument should be instance of matplotlib.ticker.FormatterFTN)	rV   ÚmtickerÚ	FormatterÚ	TypeErrorrú   r   rË   Úset_axisrg   )r<   rË   r   r   r   r„  C  s    
zAxis.set_major_formatterc             C   s6   t |tjƒstdƒ‚d| _|| j_|j| ƒ d| _dS )z’
        Set the formatter of the minor ticker.

        Parameters
        ----------
        formatter : `~matplotlib.ticker.Formatter`
        zDformatter argument should be instance of matplotlib.ticker.FormatterFTN)	rV   r‘  r’  r“  rû   r   rË   r”  rg   )r<   rË   r   r   r   r…  S  s    
zAxis.set_minor_formatterc             C   sL   t |tjƒstdƒ‚d| _|| j_| jjr8| jjj|ƒ |j	| ƒ d| _
dS )zŒ
        Set the locator of the major ticker.

        Parameters
        ----------
        locator : `~matplotlib.ticker.Locator`
        z@locator argument should be instance of matplotlib.ticker.LocatorFTN)rV   r‘  ÚLocatorr“  rø   r   rÊ   rË   Ú_set_locatorr”  rg   )r<   rÊ   r   r   r   r‚  c  s    
zAxis.set_major_locatorc             C   sL   t |tjƒstdƒ‚d| _|| j_| jjr8| jjj|ƒ |j	| ƒ d| _
dS )zŒ
        Set the locator of the minor ticker.

        Parameters
        ----------
        locator : `~matplotlib.ticker.Locator`
        z@locator argument should be instance of matplotlib.ticker.LocatorFTN)rV   r‘  r•  r“  rù   r   rÊ   rË   r–  r”  rg   )r<   rÊ   r   r   r   rƒ  u  s    
zAxis.set_minor_locatorc             C   s
   || _ dS )z‚
        Set the depth of the axis used by the picker.

        Parameters
        ----------
        pickradius :  float
        N)rè   )r<   rè   r   r   r   Úset_pickradius‡  s    zAxis.set_pickradius)r   c            O   s  |rt jddd� g }x>|D ]6}y|j|jƒ ƒ W q tk
rP   |j|ƒ Y qX qW |}|rx| jtj|ƒƒ | jƒ }n| j	tj|ƒƒ | j
ƒ }g }xrt||ƒD ]d\}	}
|
jj|	ƒ |
jj|ƒ |
jj|	ƒ |
jj|ƒ |
jjƒ rî|j|
jƒ |
jjƒ r |j|
jƒ q W d| _|S )aB  
        Set the text values of the tick labels.

        Parameters
        ----------
        ticklabels : sequence of str or of `Text`\s
            List of texts for tick labels; must include values for non-visible
            labels.
        minor : bool
            If True, set minor ticks instead of major ticks.
        **kwargs
            Text properties.

        Returns
        -------
        labels : list of `Text`\s
            For each tick, includes ``tick.label1`` if it is visible, then
            ``tick.label2`` if it is visible, in that order.
        z3.1zšAdditional positional arguments to set_ticklabels are ignored, and deprecated since Matplotlib 3.1; passing them will raise a TypeError in Matplotlib 3.3.)ÚmessageT)rY   Zwarn_deprecatedrÐ   rs  r  r…  r‘  ZFixedFormatterr  r„  r  r/  r7   rz   r  r9   rO   rg   )r<   Z
ticklabelsr   rX  rü   Z
get_labelsr¯   rL  r‹  Z
tick_labelrÔ   r   r   r   Úset_ticklabels‘  s6    




zAxis.set_ticklabelsc             C   s˜   | j |ƒ}t|ƒdkrT| jƒ \}}||kr@| jt|ƒt|ƒƒ n| jt|ƒt|ƒƒ |rv| jtj|ƒƒ | j	t|ƒƒS | j
tj|ƒƒ | jt|ƒƒS dS )z¨
        Set the locations of the tick marks from sequence ticks

        Parameters
        ----------
        ticks : sequence of floats
        minor : bool
        rƒ   N)r�  r.  r�   r#  ÚminrV  rƒ  r‘  ZFixedLocatorr  r‚  r  )r<   rL  r   ZxleftZxrightr   r   r   Ú	set_ticksÍ  s    

zAxis.set_ticksc             C   s   t dƒ‚dS )zÄ
        Get the bounding boxes for this `.axis` and its siblings
        as set by `.Figure.align_xlabels` or  `.Figure.align_ylablels`.

        By default it just gets bboxes for self.
        zDerived must overrideN)r€   )r<   Zxdirrx   r   r   r   Ú_get_tick_boxes_siblingså  s    zAxis._get_tick_boxes_siblingsc             C   s   t dƒ‚dS )zz
        Update the label position based on the bounding box enclosing
        all the ticklabels and axis spine.
        zDerived must overrideN)r€   )r<   rx   r   r   r   rQ  î  s    zAxis._update_label_positionc             C   s   t dƒ‚dS )zx
        Update the offset text position based on the sequence of bounding
        boxes of all the ticklabels.
        zDerived must overrideN)r€   )r<   rT  Úbboxes2r   r   r   rR  õ  s    z!Axis._update_offset_text_positionc             C   s   | j jj|ƒ dS )z0Pan by *numsteps* (can be positive or negative).N)r   rÊ   Úpan)r<   Znumstepsr   r   r   rž  ü  s    zAxis.panc             C   s   | j jj|ƒ dS )zAZoom in/out on axis; if *direction* is >0 zoom in, else zoom out.N)r   rÊ   Úzoom)r<   r  r   r   r   rŸ     s    z	Axis.zoomc          
   C   s@   t |tƒrddl}|jj|ƒ}| jtjddddddd|ƒƒ dS )zÖ
        Sets up axis ticks and labels treating data along this axis as dates.

        Parameters
        ----------
        tz : tzinfo or str or None
            The timezone used to create date labels.
        r   NiÙ  rƒ   )rV   rW   Zdateutil.tzÚtzZgettzr€  Údatetime)r<   r   Zdateutilr   r   r   Ú	axis_date  s    
zAxis.axis_datec             C   s
   t ƒ ‚dS )z>Return the estimated number of ticks that can fit on the axis.N)r€   )r<   r   r   r   Úget_tick_space  s    zAxis.get_tick_spacec             C   sj   | j d }| jd }tdd„ ||gD ƒƒr.dS tdd„ ||gD ƒƒrHdS tdd„ ||gD ƒƒrbdS d	S d
S )a[  
        Helper for `XAxis.get_ticks_position` and `YAxis.get_ticks_position`.

        Check the visibility of tick1line, label1, tick2line, and label2 on
        the first major and the first minor ticks, and return

        - 1 if only tick1line and label1 are visible (which corresponds to
          "bottom" for the x-axis and "left" for the y-axis);
        - 2 if only tick2line and label2 are visible (which corresponds to
          "top" for the x-axis and "right" for the y-axis);
        - "default" if only tick1line, tick2line and label1 are visible;
        - "unknown" otherwise.
        r   c             s   s:   | ]2}|j jƒ o0|jjƒ  o0|jjƒ o0|jjƒ  V  qd S )N)r1   rO   r3   r7   r9   )r   rÔ   r   r   r   r‚   *  s   z+Axis._get_ticks_position.<locals>.<genexpr>rƒ   c             s   s:   | ]2}|j jƒ o0|jjƒ  o0|jjƒ o0|jjƒ  V  qd S )N)r3   rO   r1   r9   r7   )r   rÔ   r   r   r   r‚   0  s   é   c             s   s8   | ]0}|j jƒ o.|jjƒ o.|jjƒ o.|jjƒ  V  qd S )N)r1   rO   r3   r7   r9   )r   rÔ   r   r   r   r‚   6  s   rT   ÚunknownN)rÎ   rÑ   Úall)r<   r   r   r   r   r   Ú_get_ticks_position  s    

zAxis._get_ticks_positionc             C   s   | j S )z;
        Return the label position (top or bottom)
        )Úlabel_position)r<   r   r   r   Úget_label_position?  s    zAxis.get_label_positionc             C   s
   t ƒ ‚dS )z„
        Set the label position (top or bottom)

        Parameters
        ----------
        position : {'top', 'bottom'}
        N)r€   )r<   Úpositionr   r   r   Úset_label_positionE  s    zAxis.set_label_positionc             C   s
   t ƒ ‚d S )N)r€   )r<   r   r   r   rþ   O  s    zAxis.get_minpos)rÜ   )N)r   F)N)F)F)FN)F)F)F)N)N)Nr   )N)F)N)br   r™   rš   r›   ÚOFFSETTEXTPADrÛ   r   rÌ   rÎ   rÑ   rî   rð   rœ   rj  ró   rõ   rö   rí   rý   re   rì   r  r  Ústaticmethodr  rf   r�   r#  r$  r%  r(  r*  r+  r   rY   r�   r7  rB  rC  rD  r8  r9  rU  rc   r   r    rv   rä   ræ   rZ  r[  r\  r]  r`  ra  rb  rd  re  rf  r,  r0  rm  ro  rÏ   rr  rt  ru  rv  rw  rx  r  r  rÀ   r€  r~  rˆ  r�  r
  r�  r†  r„  r…  r‚  rƒ  r—  r™  r›  rœ  rQ  rR  rž  rŸ  r¢  r£  r§  r©  r«  rþ   r   r   r   r   rÖ   §  s´   
)


		
&-


I!
"		






0"

<
	
%
rÖ   c                sF   ‡ ‡fdd„‰d	‡ ‡‡‡fdd„	‰d| › d�ˆ_ d| › d�ˆ_ ˆˆfS )
zo
    Helper to generate ``get_{data,view}_interval`` and
    ``set_{data,view}_interval`` implementations.
    c                s   t t | jˆƒˆ ƒS )N)rN   r   )r<   )Ú	attr_nameÚlim_namer   r   ÚgetterY  s    z%_make_getset_interval.<locals>.getterFc                s~   |rt t| jˆƒˆ ||fƒ nVˆ| ƒ\}}||k rTˆ| t|||ƒt|||ƒdd� n ˆ| t|||ƒt|||ƒdd� d| _d S )NT)r"  )r�   rN   r   rš  rV  rg   )r<   rÿ   r   r"  ZoldminZoldmax)r®  r°  r¯  Úsetterr   r   r±  ]  s    
z%_make_getset_interval.<locals>.setterr†   Z	_intervalÚset_)F)r   )Úmethod_namer¯  r®  r   )r®  r°  r¯  r±  r   Ú_make_getset_intervalS  s
    r´  c               @   s¼   e Zd ZdZ dZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedddƒ\ZZed d!dƒ\ZZd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*S )+ÚXAxisÚxaxisr¤   c             C   sà   | j dk	r| j | |ƒS |j|j }}y"| jjjƒ }|j||fƒ\}}W n tk
r^   di fS X | jjjdƒ\}}| jjjdƒ\}	}
d|  ko–dkn  oÖ|| j |  k o´|k n  pÖ|
|  k oÒ|
| j k n  }|i fS )z=Test whether the mouse event occurred in the x axis.
        NFr   rƒ   )r   r   )rƒ   rƒ   )	rm   r¤   r¥   r   rÙ   r)  rÚ   r  rè   )r<   rn   r¤   r¥   r’   ÚxaxesÚyaxesrº   rP  Úrr¯   Úinaxisr   r   r   ro   u  s    

zXAxis.containsc             C   s,   |r| j }n| j}t| jddfd|i|—ŽS )Nr   r  r   )rê   rë   r¡   r   )r<   r   r“   r   r   r   rÏ   ˆ  s    zXAxis._get_tickc             C   sZ   t jddtjtd td d�td ddd	�}|jtj| jj	tj
ƒ ƒƒ | j|ƒ d
| _|S )Ng      à?r   zaxes.labelsizezaxes.labelweight)r?   Úweightzaxes.labelcolorr  Úcenter)r¤   r¥   r¦   rA   r§   r¨   r  )r©   rª   r«   r¬   r   rŒ   r:  Úblended_transform_factoryr   rÙ   ÚIdentityTransformr   r¨  )r<   r>   r   r   r   rä   �  s    

zXAxis._get_labelc             C   sT   t jddtjtd d�td ddd�}|jtj| jj	tj
ƒ ƒƒ | j|ƒ d	| _|S )
Nrƒ   r   zxtick.labelsize)r?   zxtick.colorr  r  )r¤   r¥   r¦   rA   r§   r¨   r  )r©   rª   r«   r¬   r   rŒ   r:  r½  r   rÙ   r¾  r   Úoffset_text_position)r<   rç   r   r   r   ræ   ¡  s    

zXAxis._get_offset_textc             C   sD   |dkr| j jdƒ n|dkr,| j jdƒ ntdƒ‚|| _d| _dS )z„
        Set the label position (top or bottom)

        Parameters
        ----------
        position : {'top', 'bottom'}
        r  Úbaseliner  z'Position accepts only 'top' or 'bottom'TN)r>   Úset_verticalalignmentr  r¨  rg   )r<   rª  r   r   r   r«  °  s    zXAxis.set_label_positionc       
      C   sf   g }g }| j j}xLt|j| jƒƒD ]8\}}|jjƒ }|jj||ƒ\}}	|j|ƒ |j|	ƒ q"W ||fS )zÄ
        Get the bounding boxes for this `.axis` and its siblings
        as set by `.Figure.align_xlabels` or  `.Figure.align_ylablels`.

        By default it just gets bboxes for self.
        )	r   Z_align_xlabel_grpÚ	enumerateÚget_siblingsr   r¶  r8  r9  r  )
r<   rx   rT  r�  ÚgrpÚnnÚaxxr=  ÚtlbÚtlb2r   r   r   rœ  Á  s    

zXAxis._get_tick_boxes_siblingsc             C   s4  | j s
dS | j|d�\}}| jjƒ \}}| jdkr²y&| jjd }|jƒ j|j	ƒ ƒj
ƒ }W n tk
rt   | jj}Y nX tjj||g ƒ}|j}	| jj||	| j| jj d  fƒ n~y&| jjd }|jƒ j|j	ƒ ƒj
ƒ }W n tk
rô   | jj}Y nX tjj||g ƒ}|j}
| jj||
| j| jj d  fƒ dS )zy
        Update the label position based on the bounding box enclosing
        all the ticklabels and axis spine
        N)rx   r  rj   r  )râ   rœ  r>   Úget_positionr¨  r   Úspinesrõ   Útransform_pathrÂ   Úget_extentsÚKeyErrorr@  r:  r;  r<  Úy0rò   rå   r   rk   Úy1)r<   rx   rT  r�  r¤   r¥   ÚspineÚ	spinebboxr@  r  r  r   r   r   rQ  Ô  s2    
zXAxis._update_label_positionc             C   sZ   | j jƒ \}}t|ƒs"| jjj}ntjj|ƒ}|j	}| j j
||| j| jj d  fƒ dS )zw
        Update the offset_text position based on the sequence of bounding
        boxes of all the ticklabels
        rj   N)rç   rÉ  r.  r   r@  Úyminr:  r;  r<  rÎ  rò   r¬  r   rk   )r<   rT  r�  r¤   r¥   r  r@  r   r   r   rR  ÿ  s    z"XAxis._update_offset_text_positionc             C   sŽ   | j |ƒ\}}| jd jƒ }d}|jr4||j| 7 }d}|jrL||j| 7 }| jƒ dkrp|| jj|ƒj| 7 }n|| jj|ƒj| 7 }||fS )z‹
        Returns the amount of space one should reserve for text
        above and below the axes.  Returns a tuple (above, below)
        r   g        r  )rB  rÎ   rl   rO  r©  r>   rM  )r<   rx   r@  rA  Ú	padPixelsZaboveZbelowr   r   r   Úget_text_heights  s    zXAxis.get_text_heightsc             C   s¤   |dkr| j dddddd� n||dkr<| j dddddd� n^|dkrV| j dddd� nD|dkrp| j dddd� n*|d	krŽ| j dddddd� ntd
| ƒ‚d| _dS )aü  
        Set the ticks position (top, bottom, both, default or none)
        both sets the ticks to appear on both positions, but does not
        change the tick labels.  'default' resets the tick positions to
        the default: ticks on both positions, labels at bottom.  'none'
        can be used if you don't want any ticks. 'none' and 'both'
        affect only the ticks, not the labels.

        Parameters
        ----------
        position : {'top', 'bottom', 'both', 'default', 'none'}
        r  r   TF)r¸   r  r  r  r  r  )r¸   r  r  ÚnonerT   zinvalid position: %sN)r  r  rg   )r<   rª  r   r   r   Úset_ticks_position$  s"    




zXAxis.set_ticks_positionc             C   s>   d}d| j kr"| j d p | j d }| jdƒ | jd|d� dS )zP
        Move ticks and ticklabels (if present) to the top of the axes.
        TrI   rJ   r  r   )r¸   r  N)rê   rÖ  r  )r<   r>   r   r   r   Útick_topD  s    



zXAxis.tick_topc             C   s>   d}d| j kr"| j d p | j d }| jdƒ | jd|d� dS )zS
        Move ticks and ticklabels (if present) to the bottom of the axes.
        TrI   rJ   r  r   )r¸   r  N)rê   rÖ  r  )r<   r>   r   r   r   Útick_bottomP  s    



zXAxis.tick_bottomc             C   s   dddddœ| j ƒ  S )zW
        Return the ticks position ("top", "bottom", "default", or "unknown").
        r  r  rT   r¥  )rƒ   r¤  rT   r¥  )r§  )r<   r   r   r   Úget_ticks_position\  s    zXAxis.get_ticks_positionÚviewrÄ   rÅ   r  ÚdataLimc             C   s
   | j jjS )N)r   rÛ  Zminposx)r<   r   r   r   rþ   i  s    zXAxis.get_minposc             C   s,   | j ƒ \}}| jjt||f|d�d d� d S )N)Úreverse)rU   )r�   r   Zset_xlimrH  )r<   r)  r~   rP  r   r   r   r*  l  s    zXAxis.set_invertedc             C   s¬   d\}}| j jjƒ }| j jjƒ }| s,| r¢| jd k	r~| jj| j| ƒ}|jd k	r~|j\}}| jj|| j| ƒ}| jj|| j| ƒ}|s�||f| j j_	|s¢||f| j j_	d| _
d S )Nç        ç      ð?T)rÝ  rÞ  )r   rÛ  ZmutatedxrÄ   r  r�  r	  Údefault_limitsr‰  rÅ   rg   )r<   ZxminZxmaxÚdataMutatedÚviewMutatedr‡  ÚvalminÚvalmaxr   r   r   r+  q  s    


zXAxis.set_default_intervalsc             C   sz   | j jjddgddggƒ}|d d |d d  | j jj d }| jdƒ}|jjƒ d }|dkrrtt	j
|| ƒƒS d	S d S )
Nr   rƒ   rj   Tr×   r¤  é   l        iÿÿÿ)r   rÙ   ri   r   rk   rÏ   r7   Úget_sizeÚintrI  Úfloor)r<   Úendsr  rÔ   r?   r   r   r   r£  ƒ  s    &
zXAxis.get_tick_spaceN)r   r™   rš   Ú	axis_namero   rÏ   rä   ræ   r«  rœ  rQ  rR  rÔ  rÖ  r×  rØ  rÙ  r´  r�   r#  r$  r%  rþ   r*  r+  r£  r   r   r   r   rµ  q  s.   + rµ  c               @   sÄ   e Zd ZdZ dZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedd d!ƒ\ZZed"d#d!ƒ\ZZd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,S )-ÚYAxisÚyaxisr¥   c             C   sà   | j dk	r| j | |ƒS |j|j }}y"| jjjƒ }|j||fƒ\}}W n tk
r^   di fS X | jjjdƒ\}}| jjjdƒ\}	}
d|  ko–dkn  oÖ|| j |  k o´|k n  pÖ|	|  k oÒ|	| j k n  }|i fS )z_Test whether the mouse event occurred in the y axis.

        Returns *True* | *False*
        NFr   rƒ   )r   r   )rƒ   rƒ   )	rm   r¤   r¥   r   rÙ   r)  rÚ   r  rè   )r<   rn   r¤   r¥   r’   r·  r¸  rº   rP  r¹  r¯   rº  r   r   r   ro   ”  s    

zYAxis.containsc             C   s,   |r| j }n| j}t| jddfd|i|—ŽS )Nr   r  r   )rê   rë   rÆ   r   )r<   r   r“   r   r   r   rÏ   ©  s    zYAxis._get_tickc          
   C   s^   t jddtjtd td d�td ddd	d
d�}|jtjtjƒ | j	j
ƒƒ | j|ƒ d| _|S )Nr   g      à?zaxes.labelsizezaxes.labelweight)r?   r»  zaxes.labelcolorr  r¼  ZverticalÚanchor)r¤   r¥   r¦   rA   r§   r¨   r…   Zrotation_moder  )r©   rª   r«   r¬   r   rŒ   r:  r½  r¾  r   rÙ   r   r¨  )r<   r>   r   r   r   rä   °  s    

zYAxis._get_labelc             C   sT   t jddtjtd d�td ddd�}|jtj| jj	tj
ƒ ƒƒ | j|ƒ d| _|S )	Nr   g      à?zytick.labelsize)r?   zytick.colorrÀ  r  )r¤   r¥   r¦   rA   r§   r¨   )r©   rª   r«   r¬   r   rŒ   r:  r½  r   rÙ   r¾  r   r¿  )r<   rç   r   r   r   ræ   Ä  s    

zYAxis._get_offset_textc             C   s\   | j jdƒ | j jdƒ |dkr.| j jdƒ n|dkrD| j jdƒ ntdƒ‚|| _d| _d	S )
z„
        Set the label position (left or right)

        Parameters
        ----------
        position : {'left', 'right'}
        rì  r¼  r  r  r  r  z'Position accepts only 'left' or 'right'TN)r>   Zset_rotation_modeZset_horizontalalignmentrÁ  r  r¨  rg   )r<   rª  r   r   r   r«  Ô  s    zYAxis.set_label_positionc       	      C   s^   g }g }| j j}xD|j| jƒD ]4}|jjƒ }|jj||ƒ\}}|j|ƒ |j|ƒ qW ||fS )zÄ
        Get the bounding boxes for this `.axis` and its siblings
        as set by `.Figure.align_xlabels` or  `.Figure.align_ylablels`.

        By default it just gets bboxes for self.
        )r   Z_align_ylabel_grprÃ  r   rë  r8  r9  r  )	r<   rx   rT  r�  rÄ  rÆ  r=  rÇ  rÈ  r   r   r   rœ  ç  s    

zYAxis._get_tick_boxes_siblingsc             C   s4  | j s
dS | j|d�\}}| jjƒ \}}| jdkr²y&| jjd }|jƒ j|j	ƒ ƒj
ƒ }W n tk
rt   | jj}Y nX tjj||g ƒ}|j}	| jj|	| j| jj d  |fƒ n~y&| jjd }|jƒ j|j	ƒ ƒj
ƒ }W n tk
rô   | jj}Y nX tjj||g ƒ}|j}
| jj|
| j| jj d  |fƒ dS )zy
        Update the label position based on the bounding box enclosing
        all the ticklabels and axis spine
        N)rx   r  rj   r  )râ   rœ  r>   rÉ  r¨  r   rÊ  rõ   rË  rÂ   rÌ  rÍ  r@  r:  r;  r<  Zx0rò   rå   r   rk   Úx1)r<   rx   rT  r�  r¤   r¥   rÐ  rÑ  r@  r  r  r   r   r   rQ  ú  s2    
zYAxis._update_label_positionc             C   s>   | j jƒ \}}| jjj}| j j||| j| jj d  fƒ dS )zw
        Update the offset_text position based on the sequence of bounding
        boxes of all the ticklabels
        rj   N)	rç   rÉ  r   r@  Úymaxrò   r¬  r   rk   )r<   rT  r�  r¤   r¥   r  r   r   r   rR  $	  s    
z"YAxis._update_offset_text_positionc             C   sX   | j jƒ \}}|dkrd}n|dkr*d}ntdƒ‚| j j|ƒ | j j||fƒ d| _dS )zT
        Parameters
        ----------
        position : {'left', 'right'}
        r  r   r  rƒ   z*Position accepts only [ 'left' | 'right' ]TN)rç   rÉ  r  Zset_harò   rg   )r<   rª  r¤   r¥   r   r   r   Úset_offset_position/	  s    zYAxis.set_offset_positionc             C   sŽ   | j |ƒ\}}| jd jƒ }d}|jr4||j| 7 }d}|jrL||j| 7 }| jƒ dkrp|| jj|ƒj| 7 }n|| jj|ƒj| 7 }||fS )Nr   g        r  )rB  rÎ   rl   r@   r©  r>   rM  )r<   rx   r@  rA  rÓ  r  r  r   r   r   Úget_text_widthsA	  s    zYAxis.get_text_widthsc             C   s¸   |dkr(| j dddddd� | j|ƒ n†|dkrP| j dddddd� | j|ƒ n^|dkrj| j dddd� nD|dkr„| j dddd� n*|d	kr¢| j dddddd� ntd
| ƒ‚d| _dS )aü  
        Set the ticks position (left, right, both, default or none)
        'both' sets the ticks to appear on both positions, but does not
        change the tick labels.  'default' resets the tick positions to
        the default: ticks on both positions, labels at left.  'none'
        can be used if you don't want any ticks. 'none' and 'both'
        affect only the ticks, not the labels.

        Parameters
        ----------
        position : {'left', 'right', 'both', 'default', 'none'}
        r  r   TF)r¸   r  r  r  r  r  )r¸   r  r  rÕ  rT   zinvalid position: %sN)r  rï  r  rg   )r<   rª  r   r   r   rÖ  S	  s&    






zYAxis.set_ticks_positionc             C   s>   d}d| j kr"| j d p | j d }| jdƒ | jd|d� dS )zR
        Move ticks and ticklabels (if present) to the right of the axes.
        TrI   rJ   r  r   )r¸   r  N)rê   rÖ  r  )r<   r>   r   r   r   Ú
tick_rightu	  s    



zYAxis.tick_rightc             C   s>   d}d| j kr"| j d p | j d }| jdƒ | jd|d� dS )zQ
        Move ticks and ticklabels (if present) to the left of the axes.
        TrI   rJ   r  r   )r¸   r  N)rê   rÖ  r  )r<   r>   r   r   r   Ú	tick_left‚	  s    



zYAxis.tick_leftc             C   s   dddddœ| j ƒ  S )zW
        Return the ticks position ("left", "right", "default", or "unknown").
        r  r  rT   r¥  )rƒ   r¤  rT   r¥  )r§  )r<   r   r   r   rÙ  �	  s    zYAxis.get_ticks_positionrÚ  rÄ   rÈ   r  rÛ  c             C   s
   | j jjS )N)r   rÛ  Zminposy)r<   r   r   r   rþ   œ	  s    zYAxis.get_minposc             C   s,   | j ƒ \}}| jjt||f|d�d d� d S )N)rÜ  )rU   )r�   r   Zset_ylimrH  )r<   r)  r~   rP  r   r   r   r*  Ÿ	  s    zYAxis.set_invertedc             C   s¬   d\}}| j jjƒ }| j jjƒ }| s,| r¢| jd k	r~| jj| j| ƒ}|jd k	r~|j\}}| jj|| j| ƒ}| jj|| j| ƒ}|s�||f| j j_	|s¢||f| j j_	d| _
d S )Nç        ç      ð?T)ró  rô  )r   rÛ  ZmutatedyrÄ   r  r�  r	  rß  r‰  rÈ   rg   )r<   rÒ  rî  rà  rá  r‡  râ  rã  r   r   r   r+  ¤	  s    


zYAxis.set_default_intervalsc             C   sz   | j jjddgddggƒ}|d d |d d  | j jj d }| jdƒ}|jjƒ d }|dkrrtt	j
|| ƒƒS d	S d S )
Nr   rƒ   rj   Tg       @r¤  rä  l        iÿÿÿ)r   rÙ   ri   r   rk   rÏ   r7   rå  ræ  rI  rç  )r<   rè  r  rÔ   r?   r   r   r   r£  ¶	  s    &
zYAxis.get_tick_spaceN)r   r™   rš   ré  ro   rÏ   rä   ræ   r«  rœ  rQ  rR  rï  rð  rÖ  rñ  rò  rÙ  r´  r�   r#  r$  r%  rþ   r*  r+  r£  r   r   r   r   rê  �  s0   *"rê  )8r›   r¡  ÚloggingZnumpyrI  Z
matplotlibr   Zmatplotlib.artistry   r   Zmatplotlib.cbookrY   Zmatplotlib.font_managerr«   Zmatplotlib.linesrc  r%   Zmatplotlib.scaleZscaler÷   Zmatplotlib.textÚtextr©   Zmatplotlib.tickerZtickerr‘  Zmatplotlib.transformsZ
transformsr:  Zmatplotlib.unitsr	  r{  Ú	getLoggerr   Ú_logrÁ   ZArtistInspectorr&   Z_line_AIZget_settersZ_line_param_namesZaliasdrW  Z_line_param_aliasesr‡   r   r   r¡   rÆ   ÚobjectrÉ   rÌ   rÖ   r´  rµ  rê  r   r   r   r   Ú<module>   sT   









  nuu          5  !