B
    ]”t\»b ã               @   s  d Z ddlZddlZddl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 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 %e&¡Z'dZ(e	 )ej*¡Z+e+ ,¡ Z-dd„ e+j. /¡ D ƒZ0d	d„ e-e0 D ƒZ1G d
d„ de	j2ƒZ3G dd„ de3ƒZ4G dd„ de3ƒZ5G dd„ de6ƒZ7G dd„ de6ƒZ8G dd„ de	j2ƒZ9G dd„ de9ƒZ:G dd„ de9ƒZ;dS )z(
Classes for the ticks and x and y axis
é    N)ÚrcParams)Úallow_rasterization)Ú_string_to_boolé´   c             C   s   g | ]}t |ƒd  ‘qS )r   )Úlist)Ú.0Úd© r	   ú.lib/python3.7/site-packages/matplotlib/axis.pyú
<listcomp>!   s    r   c             C   s   g | ]}d | ‘qS )Úgrid_r	   )r   Únamer	   r	   r
   r   "   s   c               @   sø   e Zd ZdZd:dd„Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Z	d;dd„Z
ejj
je
_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)„ ƒZd*d+„ ZeZd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Z d8d9„ Z!dS )<ÚTickaÝ  
    Abstract base class for the axis ticks, grid lines and labels

    1 refers to the bottom of the plot for xticks and the left for yticks
    2 refers to the top of the plot for xticks and the right for yticks

    Attributes
    ----------
    tick1line : Line2D

    tick2line : Line2D

    gridline : Line2D

    label1 : Text

    label2 : Text

    gridOn : bool
        Determines whether to draw the tickline.

    tick1On : bool
        Determines whether to draw the first tickline.

    tick2On : bool
        Determines whether to draw the second tickline.

    label1On : bool
        Determines whether to draw the first tick label.

    label2On : bool
        Determines whether to draw the second tick label.
    NTFr   c             K   sh  t j | ¡ |dkrL|r.td dkr.td }n|sHtd dkrHtd }nd}|  |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rHtd|  }	|	| _|  |¡ |dkr~|rvt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„ | ¡ D ƒ| _|  |¡ |  ¡ | _|  ¡ | _ |  !¡ | _"|  #¡ | _$| 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)r   Ú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>).ÚartistÚ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ÚlabelÚ
_get_text2Úlabel2ÚgridOnÚtick1OnÚtick2OnÚlabel1OnÚlabel2OnÚupdate_position)Úselfr   Úlocr:   ÚsizeÚwidthÚcolorÚtickdirÚpadÚ	labelsizeÚ
labelcolorr)   r=   r>   r?   r@   rA   r   ÚlabelrotationZ
grid_colorZgrid_linestyleZgrid_linewidthZ
grid_alphaÚkwr   r	   r	   r
   r   H   sz    














zTick.__init__c             C   sX   t |tƒr|}d}n t |ttfƒr,|\}}nd}|}|dkrJtd |¡ƒ‚||f| _d S )Nr   Údefault)ÚautorN   z:Label rotation mode must be 'default' or 'auto', not '{}'.)Ú
isinstanceÚstrÚtupler   Ú
ValueErrorÚformatÚ_labelrotation)rC   rL   ÚmodeZangler	   r	   r
   r&   ¾   s    

zTick._set_labelrotationc             C   s   dS )z;
        Calculate self._pad and self._tickmarkers
        Nr	   )rC   rH   r	   r	   r
   r1   Ì   s    zTick.apply_tickdirc             C   s   | j S )N)Ú_tickdir)rC   r	   r	   r
   Úget_tickdirÒ   s    zTick.get_tickdirc             C   s   ddddœ}| j || j  S )zA
        Get the length of the tick outside of the axes.
        g        g      à?g      ð?)ÚinÚinoutÚout)r    rW   )rC   Zpaddingr	   r	   r
   Úget_tick_paddingÕ   s    zTick.get_tick_paddingc             C   s   | j | j| j| j| jg}|S )N)r3   r5   r7   r9   r<   )rC   Úchildrenr	   r	   r
   Úget_childrenà   s    zTick.get_childrenc             C   s(   t j | ||¡ | j ||¡ d| _d S )NT)r   r   Úset_clip_pathr7   Ústale)rC   ÚclippathÚ	transformr	   r	   r
   r_   å   s    zTick.set_clip_pathc             C   s   | j j| j d S )NéH   )r   Údpir#   )rC   r	   r	   r
   Úget_pad_pixelsì   s    zTick.get_pad_pixelsc             C   s   t | jƒr|  | |¡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.
        F)ÚcallableÚ	_contains)rC   Ú
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
        )rI   TN)Ú_apply_paramsr`   )rC   Ú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#   )rC   r	   r	   r
   Úget_pad  s    zTick.get_padc             C   s   dS )zGet the default Text 1 instanceNr	   )rC   r	   r	   r
   r8   	  s    zTick._get_text1c             C   s   dS )zGet the default Text 2 instanceNr	   )rC   r	   r	   r
   r;     s    zTick._get_text2c             C   s   dS )z)Get the default line2D instance for tick1Nr	   )rC   r	   r	   r
   r2     s    zTick._get_tick1linec             C   s   dS )z)Get the default line2D instance for tick2Nr	   )rC   r	   r	   r
   r4     s    zTick._get_tick2linec             C   s   dS )z2Get the default grid Line2d instance for this tickNr	   )rC   r	   r	   r
   r6     s    zTick._get_gridlinec             C   s   | j S )z2Return the tick location (data coords) as a scalar)r   )rC   r	   r	   r
   Úget_loc  s    zTick.get_locc             C   sŽ   |   ¡ sd| _d S | | j¡ | jr0| j |¡ | jrB| j |¡ | j	rT| j
 |¡ | jrf| j |¡ | jrx| j |¡ | | j¡ d| _d S )NF)Úget_visibler`   Ú
open_groupr   r=   r7   Údrawr>   r3   r?   r5   r@   r9   rA   r<   Úclose_group)rC   Úrendererr	   r	   r
   rq   !  s     z	Tick.drawc             C   s   | j  |¡ d| _dS )z]
        Set the label1 text.

        Parameters
        ----------
        s : str
        TN)r9   Úset_textr`   )rC   Úsr	   r	   r
   Ú
set_label17  s    zTick.set_label1c             C   s   | j  |¡ d| _dS )z]
        Set the label2 text.

        Parameters
        ----------
        s : str
        TN)r<   rt   r`   )rC   ru   r	   r	   r
   Ú
set_label2D  s    zTick.set_label2c             C   s   |  | j¡ d S )N)r   r   )rC   Úar	   r	   r
   Ú_set_artist_propsO  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)rC   r	   r	   r
   Úget_view_intervalR  s    zTick.get_view_intervalc       
         sR  x&dD ]}|ˆ krt | |ˆ  |¡ƒ qW t‡ fdd„dD ƒƒrˆ  d| j¡| _ˆ  d| j¡| _ˆ  d| j¡| _|  ˆ  d| j¡¡ | j 	| j
d	 ¡ | j 	| j
d
 ¡ x,| j| jfD ]}| | j¡ | | j¡ q¶W |  ¡ d	 }| j |¡ |  ¡ d	 }| j |¡ dd„ ˆ  ¡ D ƒ}| jjf |Ž | jjf |Ž x&| ¡ D ]\}}t | d| |ƒ q>W dˆ krž|  ˆ  d¡¡ | jj| jd
 d | jj| jd
 d dd„ ˆ  ¡ D ƒ}| jjf |Ž | jjf |Ž x8| ¡ D ],\}}t| jd| ƒƒ }t | d| |ƒ qÖW dd„ ˆ  ¡ D ƒ}	| jjf |	Ž x&|	 ¡ D ]\}}t | d| |ƒ q0W d S )N)r=   r>   r?   r@   rA   c             3   s   | ]}|ˆ kV  qd S )Nr	   )r   r   )rM   r	   r
   ú	<genexpr>Z  s    z%Tick._apply_params.<locals>.<genexpr>)rE   rF   rI   rH   rE   rF   rI   rH   r   é   c             S   s   i | ]\}}|d kr||“qS ))rG   r)   r	   )r   r   r   r	   r	   r
   r   m  s    z&Tick._apply_params.<locals>.<dictcomp>Ú_rL   )Úrotationc             S   s&   i | ]\}}|d kr||dd… “qS ))rJ   rK   r   Nr	   )r   r   r   r	   r	   r
   r   x  s    Z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_)ÚsetattrÚpopÚanyr    r!   r#   r1   rW   r3   Z
set_markerÚ_tickmarkersr5   Zset_markersizeZset_markeredgewidthÚ_get_text1_transformr9   Úset_transformÚ_get_text2_transformr<   r/   Úsetr&   rU   Úgetattrr7   )
rC   rM   r   ÚlineÚtransÚtick_kwr   r   Zlabel_kwZgrid_kwr	   )rM   r
   rj   V  sH    

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)rz   )rC   rD   r	   r	   r
   rB   ‰  s    zTick.update_positionc             C   s   t dƒ‚d S )NzDerived must override)rz   )rC   r	   r	   r
   r…     s    zTick._get_text1_transformc             C   s   t dƒ‚d S )NzDerived must override)rz   )rC   r	   r	   r
   r‡     s    zTick._get_text2_transform)NNNNNNNNNTTTFTr   NNNN)N)"r   Ú
__module__Ú__qualname__Ú__doc__r   r&   r1   rX   r\   r^   r_   r   r   re   ri   rl   rm   r8   r;   r2   r4   r6   rn   r   rq   rv   Z	set_labelrw   ry   r{   rj   rB   r…   r‡   r	   r	   r	   r
   r   &   s^   !                  
b
3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¡S )N)r   Zget_xaxis_text1_transformÚ_pad)rC   r	   r	   r
   r…   ›  s    zXTick._get_text1_transformc             C   s   | j  | j¡S )N)r   Zget_xaxis_text2_transformr‘   )rC   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|  ¡  | _	d| _
d S )Nz%s.directionrY   rZ   )ú|r’   T)r   r   rW   r'   ZTICKUPZTICKDOWNr„   r#   r\   r‘   r`   )rC   rH   r	   r	   r
   r1   ¡  s    

zXTick.apply_tickdirc             C   sH   |   ¡ \}}}tjddtj| jd| j||d}| |¡ |  |¡ |S )zGet the default Text instancer   )rE   )ÚxÚyÚfontpropertiesrG   ÚverticalalignmentÚhorizontalalignment)	r…   ÚmtextÚTextÚfont_managerÚFontPropertiesr%   r$   r†   ry   )rC   r‹   ÚvertÚhorizÚtr	   r	   r
   r8   ¯  s    

zXTick._get_text1c             C   sH   |   ¡ \}}}tjddtj| jd| j||d}| |¡ |  |¡ |S )zGet the default Text 2 instancer   r}   )rE   )r“   r”   r•   rG   r–   r—   )	r‡   r˜   r™   rš   r›   r%   r$   r†   ry   )rC   r‹   rœ   r   rž   r	   r	   r
   r;   À  s    

zXTick._get_text2c          
   C   sJ   t jdd| jd| jd | j| j| jd}| | jj	dd¡ |  
|¡ |S )zGet the default line2D instance)r   ÚNoner   )ÚxdataÚydatarG   Ú	linestyleÚmarkerÚ
markersizeÚmarkeredgewidthr)   Útick1)Úwhich)r'   r(   r"   r„   r    r!   r*   r†   r   Úget_xaxis_transformry   )rC   Úlr	   r	   r
   r2   Ð  s    

zXTick._get_tick1linec          
   C   sJ   t jdd| jd| jd | j| j| jd}| | jj	dd¡ |  
|¡ |S )zGet the default line2D instance)r   )r}   rŸ   r}   )r    r¡   rG   r¢   r£   r¤   r¥   r)   Útick2)r§   )r'   r(   r"   r„   r    r!   r*   r†   r   r¨   ry   )rC   r©   r	   r	   r
   r4   Û  s    

zXTick._get_tick2linec          
   C   sV   t jf dd| j| j| j| jddœ| j—Ž}| | jj	dd¡ t
| ¡ _|  |¡ |S )zGet the default line2D instance)g        g        )r   g      ð?r   )r    r¡   rG   r¢   Ú	linewidthÚalphar¤   Úgrid)r§   )r'   r(   r+   r,   r-   r.   r0   r†   r   r¨   ÚGRIDLINE_INTERPOLATION_STEPSÚget_pathÚ_interpolation_stepsry   )rC   r©   r	   r	   r
   r6   ê  s    



zXTick._get_gridlinec             C   sp   | j r| j |f¡ | jr(| j |f¡ | jr<| j |f¡ | jrN| j 	|¡ | j
r`| j 	|¡ || _d| _dS )z9Set the location of tick in data coords with scalar *loc*TN)r>   r3   Z	set_xdatar?   r5   r=   r7   r@   r9   Zset_xrA   r<   r   r`   )rC   rD   r	   r	   r
   rB   ú  s    zXTick.update_positionc             C   s
   | j jjS )z6return the Interval instance for this axis view limits)r   ÚviewLimÚ	intervalx)rC   r	   r	   r
   r{   
  s    zXTick.get_view_intervalN)r   r   rŽ   r   r…   r‡   r1   r8   r;   r2   r4   r6   rB   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¡S )N)r   Zget_yaxis_text1_transformr‘   )rC   r	   r	   r
   r…     s    zYTick._get_text1_transformc             C   s   | j  | j¡S )N)r   Zget_yaxis_text2_transformr‘   )rC   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|  ¡  | _	d| _
d S )Nz%s.directionrY   rZ   )r~   r~   T)r   r   rW   r'   Z	TICKRIGHTZTICKLEFTr„   r#   r\   r‘   r`   )rC   rH   r	   r	   r
   r1     s    

zYTick.apply_tickdirc             C   sH   |   ¡ \}}}tjddtj| jd| j||d}| |¡ |  |¡ |S )zGet the default Text instancer   )rE   )r“   r”   r•   rG   r–   r—   )	r…   r˜   r™   rš   r›   r%   r$   r†   ry   )rC   r‹   rœ   r   rž   r	   r	   r
   r8   +  s    

zYTick._get_text1c             C   sH   |   ¡ \}}}tjddtj| jd| j||d}| |¡ |  |¡ |S )zGet the default Text instancer}   r   )rE   )r“   r”   r•   rG   r–   r—   )	r‡   r˜   r™   rš   r›   r%   r$   r†   ry   )rC   r‹   rœ   r   rž   r	   r	   r
   r;   :  s    

zYTick._get_text2c          
   C   sJ   t jdd| j| jd d| j| j| jd}| | jj	dd¡ |  
|¡ |S )zGet the default line2D instance)r   r   rŸ   )rG   r£   r¢   r¤   r¥   r)   r¦   )r§   )r'   r(   r"   r„   r    r!   r*   r†   r   Úget_yaxis_transformry   )rC   r©   r	   r	   r
   r2   I  s    

zYTick._get_tick1linec          
   C   sJ   t jdd| j| jd d| j| j| jd}| | jj	dd¡ |  
|¡ |S )zGet the default line2D instance)r}   )r   r}   rŸ   )rG   r£   r¢   r¤   r¥   r)   rª   )r§   )r'   r(   r"   r„   r    r!   r*   r†   r   r´   ry   )rC   r©   r	   r	   r
   r4   X  s    

zYTick._get_tick2linec          
   C   sV   t jf dd| j| j| j| jddœ| j—Ž}| | jj	dd¡ t
| ¡ _|  |¡ |S )zGet the default line2D instance)r   r}   )r   r   r   )r    r¡   rG   r¢   r«   r¬   r¤   r­   )r§   )r'   r(   r+   r,   r-   r.   r0   r†   r   r´   r®   r¯   r°   ry   )rC   r©   r	   r	   r
   r6   f  s    



zYTick._get_gridlinec             C   sp   | j r| j |f¡ | jr(| j |f¡ | jr<| j |f¡ | jrN| j 	|¡ | j
r`| j 	|¡ || _d| _dS )z9Set the location of tick in data coords with scalar *loc*TN)r>   r3   Z	set_ydatar?   r5   r=   r7   r@   r9   Zset_yrA   r<   r   r`   )rC   rD   r	   r	   r
   rB   u  s    zYTick.update_positionc             C   s
   | j jjS )z6return the Interval instance for this axis view limits)r   r±   Ú	intervaly)rC   r	   r	   r
   r{   …  s    zYTick.get_view_intervalN)r   r   rŽ   r   r…   r‡   r1   r8   r;   r2   r4   r6   rB   r{   r	   r	   r	   r
   r³     s   r³   c               @   s   e Zd ZdZdZdS )ÚTickerN)r   r   rŽ   ÚlocatorÚ	formatterr	   r	   r	   r
   r¶   Š  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)rC   r   r	   r	   r
   r   —  s    z_LazyTickList.__init__c             C   s^   |d kr| S | j r6g |_|jdd}|j |¡ |jS g |_|jdd}|j |¡ |jS d S )NT)r   F)rº   Ú
majorTicksÚ	_get_tickÚappendÚ
minorTicks)rC   Ú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d„Z
dd„ Zdd„ Zdd„ Zdd„ Zee d¡dd„ ƒƒZeje d¡dd„ ƒƒZdd„ Zdd„ Zdd„ Zd¬d!d"„Zed­d#d$„ƒZd®d%d&„Zd'd(„ Zd¯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%d=d>„ Z&d?d@„ Z'dAdB„ Z(e)dCdD„ ƒZ*dEdF„ Z+dGdH„ Z,dIdJ„ Z-dKdL„ Z.dMdN„ Z/dOdP„ Z0dQdR„ Z1dSdT„ Z2d°dUdV„Z3dWdX„ Z4dYdZ„ Z5d±d[d\„Z6d]d^„ Z7d_d`„ Z8d²dadb„Z9d³dcdd„Z:dedf„ Z;dgdh„ Z<didj„ Z=dkdl„ Z>dmdn„ Z?dodp„ Z@dqdr„ ZAd´dsdt„ZBdµdudv„ZCd¶dwdx„ZDdydz„ ZEd{d|„ ZFd}d~„ ZGdd€„ ZHdd‚„ ZIdƒd„„ ZJd·d…d†„ZKd‡dˆ„ ZLd‰dŠ„ ZMd‹dŒ„ ZNddŽ„ ZOdd„ ZPd
d‘œd’d“„ZQd¸d”d•„ZRd–d—„ ZSd˜d™„ ZTdšd›„ ZUdœd„ ZVdždŸ„ ZWd¹d d¡„ZXd¢d£„ ZYd¤d¥„ ZZd¦d§„ Z[d¨d©„ Z\dS )ºÚAxiszó
    Public attributes

    * :attr:`axes.transData` - transform data coords to display coords
    * :attr:`axes.transAxes` - transform axis coords to display coords
    * :attr:`labelpad` - number of points between the axis and its label
    é   c             C   s   | j jdt| jj d¡ƒ  S )Nz(%f,%f))r   r   )Ú	__class__r   rR   r   Ú	transAxesÚtransform_point)rC   r	   r	   r
   Ú__str__¹  s    zAxis.__str__é   c             C   s”   t j | ¡ |  |j¡ d| _|| _tƒ | _tƒ | _	t
 ¡ | _d| _d| _|  ¡ | _td | _|  ¡ | _|| _tƒ | _tƒ | _|  ¡  |  d¡ dS )z=
        Init the axis with the parent Axes instance
        TFzaxes.labelpadÚlinearN)r   r   r   r   r   ÚisDefault_labelr   r¶   r   r   ÚcbookÚCallbackRegistryÚ	callbacksÚ_autolabelposÚ_smart_boundsÚ
_get_labelr:   r   ÚlabelpadÚ_get_offset_textÚ
offsetTextÚ
pickradiusÚdictÚ_major_tick_kwÚ_minor_tick_kwÚclaÚ
_set_scale)rC   r   rÕ   r	   r	   r
   r   ½  s"    



zAxis.__init__T)r   FNc             C   s<   d| _ |dkr| 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_positionr`   )rC   r“   r”   rb   r	   r	   r
   Úset_label_coordsá  s    zAxis.set_label_coordsc             C   s
   | j  ¡ S )N)Ú_scaleÚget_transform)rC   r	   r	   r
   rÞ   ø  s    zAxis.get_transformc             C   s   | j jS )N)rÝ   r   )rC   r	   r	   r
   Ú	get_scaleû  s    zAxis.get_scalec             K   s:   t j|| f|Ž| _| 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)rC   ÚvalueÚkwargsr	   r	   r
   rÚ   þ  s    zAxis._set_scalec             C   s   | j  |||  ¡ ¡S )N)rÝ   Úlimit_range_for_scaleÚ
get_minpos)rC   ÚvminÚvmaxr	   r	   r
   rç     s    zAxis.limit_range_for_scalez2.2.0c             C   s   | j S )N)Úunits)rC   r	   r	   r
   Ú	unit_data
  s    zAxis.unit_datac             C   s   |   |¡ d S )N)Ú	set_units)rC   rì   r	   r	   r
   rì     s    c             C   s4   | j | jg}|  ¡ }|  ¡ }| |¡ | |¡ |S )N)r:   rÔ   Úget_major_ticksÚget_minor_ticksÚextend)rC   r]   Z
majorticksZ
minorticksr	   r	   r
   r^     s    

zAxis.get_childrenc             C   st   | j  d¡ |  d¡ t ¡ | _td o2td dk| _td oHtd dk| _|  	¡  d| _
d| _|  d¡ d| _dS )	zclear the current axisÚ rÊ   z	axes.gridzaxes.grid.which)r   r   )r   r   NT)r:   rt   rÚ   rÌ   rÍ   rÎ   r   Ú_gridOnMajorÚ_gridOnMinorÚreset_ticksÚ	converterrë   rí   r`   )rC   r	   r	   r
   rÙ     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¡ 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¾   r_   r   Zpatch)rC   r	   r	   r
   rô   4  s    zAxis.reset_ticksr   c             K   sú   g }|dks|dkr |  | j¡ |dks0|dkr<|  | j¡ | j|dd}x"|D ]}|r`| ¡  | |¡ qPW |r||  ¡  nt|dksŒ|dkrªx| jD ]}|jf | jŽ q”W |dksº|dkrØx| j	D ]}|jf | jŽ qÂW d|krð| 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   T)Ú
to_init_kwrK   N)r½   r×   rØ   Ú_translate_tick_kwÚclearÚupdaterô   r»   rj   r¾   rÔ   Z	set_colorr`   )rC   r§   ÚresetrM   ZdictsÚkwtransr   rÁ   r	   r	   r
   Úset_tick_paramsH  s*    

zAxis.set_tick_paramsc       	      C   sÔ  ddddddddd	d
dddg}dddddddddddg}t }|| | }tƒ }|rÈd| krj|  d¡|d< d| kr€|  d¡|d< d| kr–|  d¡|d< d| kr°t|  d¡ƒ|d
< d| krÊt|  d¡ƒ|d
< d| krät|  d¡ƒ|d< d| krþt|  d¡ƒ|d< d| krt|  d¡ƒ|d< d| kr6t|  d¡ƒ|d< d| krRt|  d¡ƒ|d< d| krnt|  d¡ƒ|d< d| kr’|  d¡}||d< ||d< x(| D ] }||kr˜td||f ƒ‚q˜W | | ¡ ntdƒ‚|S )NrE   rF   rG   rH   rI   rJ   rK   r)   r=   r>   r?   r@   rA   ÚlengthÚ	directionÚleftÚbottomÚrightÚtopÚ	labelleftÚlabelbottomÚ
labelrightÚlabeltoprL   r   Zcolorsz3keyword %s is not recognized; valid keywords are %szInverse translation is deferred)r€   rÖ   r‚   r   rS   rú   rz   )	rM   r÷   Zkwkeys0Zkwkeys1Zkwkeys2Zkwkeysrü   ÚcÚkeyr	   r	   r
   rø   g  sX    








zAxis._translate_tick_kwc             C   s<   t j | ||¡ x | j| j D ]}| ||¡ qW d| _d S )NT)r   r   r_   r»   r¾   r`   )rC   ra   rb   Zchildr	   r	   r
   r_   ›  s    zAxis.set_clip_pathc             C   s   t dƒ‚dS )z6return the Interval instance for this axis view limitszDerived must overrideN)rz   )rC   r	   r	   r
   r{   ¡  s    zAxis.get_view_intervalc             C   s   t dƒ‚d S )NzDerived must override)rz   )rC   ré   rê   Úignorer	   r	   r
   Úset_view_interval¥  s    zAxis.set_view_intervalc             C   s   t dƒ‚dS )z6return the Interval instance for this axis data limitszDerived must overrideN)rz   )rC   r	   r	   r
   Úget_data_interval¨  s    zAxis.get_data_intervalc             C   s   t dƒ‚dS )zset the axis data limitszDerived must overrideN)rz   )rC   r	   r	   r
   Úset_data_interval¬  s    zAxis.set_data_intervalc             C   s   dS )zZset the default limits for the axis data and view interval if they
        are not mutatedNr	   )rC   r	   r	   r
   Úset_default_intervals°  s    zAxis.set_default_intervalsc             C   s   |d krd S |  | j¡ d S )N)r   r   )rC   rx   r	   r	   r
   ry   ¾  s    zAxis._set_artist_propsc       	      #   s¬   ˆ j  ¡ }ˆ  t|ƒ¡}ˆ j j |¡ ‡ fdd„t|ƒD ƒ}ˆ j ¡ }ˆ  t|ƒ¡}ˆ jj |¡ ‡ fdd„t|ƒD ƒ}|||f|||fg}x|D ]}t	|Ž E dH  q’W dS )zC
        Iterate through all of the major and minor ticks.
        c                s   g | ]\}}ˆ j  ||¡‘qS r	   )r   r¸   )r   Úirk   )rC   r	   r
   r   Ê  s   z#Axis.iter_ticks.<locals>.<listcomp>c                s   g | ]\}}ˆ j  ||¡‘qS r	   )r   r¸   )r   r  rk   )rC   r	   r
   r   Ð  s   N)
r   r·   rî   Úlenr¸   Zset_locsÚ	enumerater   rï   Úzip)	rC   Z	majorLocsr»   ZmajorLabelsZ	minorLocsr¾   ZminorLabelsZmajor_minorÚgroupr	   )rC   r
   Ú
iter_ticksÃ  s    




zAxis.iter_ticksc             C   sr   |   |¡}|  ||¡\}}t|ƒr0tj |¡}ntj dddd¡}t|ƒrXtj |¡}nt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)rC   rs   Ú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 boundsTN)rÐ   r`   )rC   rå   r	   r	   r
   Úset_smart_boundsî  s    zAxis.set_smart_boundsc             C   s   | j S )z%get whether the axis has smart bounds)rÐ   )rC   r	   r	   r
   Úget_smart_boundsó  s    zAxis.get_smart_boundsc          	      s  |   ¡ }t|  ¡ ƒ}| jrÊ|rÊt|ƒ\}}t|  ¡ ƒ\}}t dd„ |D ƒ¡}||kr\|‰n&|||k }	t|	ƒrz|	d ‰n|d ‰||kr|‰ n&|||k }	t|	ƒr®|	d ‰ n|d ‰ ‡ ‡fdd„|D ƒ}|d |d krà|}
n|d |d f}
t	| dƒr¬tj
dd	† y|  |
d d
¡}W n   t d¡ d}Y nX t |¡rJd}y|  |
d d¡}W n   t d¡ d}Y nX t |¡rŠd}W dQ R X |
d | |
d | f}
g }x\|D ]T\}}}|dkrÎq¶| |¡ | |¡ | |¡ t |
|¡sþq¶| |¡ q¶W |S )z
        Update ticks (position and labels) using the current data
        interval of the axes. Returns a list of ticks that will be
        drawn.
        c             S   s   g | ]}|d  ‘qS )r}   r	   )r   Útir	   r	   r
   r     s    z&Axis._update_ticks.<locals>.<listcomp>éÿÿÿÿr   c                s,   g | ]$}ˆ|d    kr ˆ krn q|‘qS )r}   r	   )r   r"  )ÚihighÚilowr	   r
   r     s    r}   Ú_get_pixel_distance_along_axisr
  )Zinvalidg      à¿zlUnable to find pixel distance along axis for interval padding of ticks; assuming no interval padding needed.g        g      à?N)r{   r   r  rÐ   Úsortedr  ÚnpÚsortr  ÚhasattrZerrstater&  ÚwarningsÚwarnZisnanrB   rv   rw   r  Zinterval_containsr½   )rC   rs   ZintervalZ	tick_tupsZview_lowZ	view_highZdata_lowZ	data_highZlocsZ	good_locsZinterval_expandedZds1Zds2r  rÁ   rD   r:   r	   )r$  r%  r
   r  ÷  sj    











zAxis._update_ticksc             C   sj   g }g }xX|D ]P}|j r8|j ¡ r8|j |¡}| |¡ |jr|j ¡ r|j |¡}| |¡ qW ||fS )zƒ
        Given the list of ticks, return two lists of bboxes. One for
        tick lable1's and another for tick label2's.
        )r@   r9   ro   Úget_window_extentr½   rA   r<   )rC   Úticksrs   r  r  rÁ   Zextentr	   r	   r
   r  Z  s    

zAxis._get_tick_bboxesc       	      C   sÜ   |   ¡ sdS |  |¡}|  |¡ |  ||¡\}}|  ||¡ | j | jj 	¡ ¡ g }xH| j
| jgD ]8}| |¡}t |j¡rbt |j¡rb|  ¡ rb| |¡ qbW | |¡ | |¡ dd„ |D ƒ}|rÔt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             S   s$   g | ]}|j d ks|jd kr|‘qS )r   )rF   Úheight)r   Úbr	   r	   r
   r   Š  s    z&Axis.get_tightbbox.<locals>.<listcomp>)ro   r  Ú_update_label_positionr  Ú_update_offset_text_positionrÔ   rt   r   r¸   Ú
get_offsetr:   r-  r(  ZisfiniterF   r/  r½   rð   r  r  r  )	rC   rs   r  r  r  Zbbrx   r  Z_bboxr	   r	   r
   Úget_tightbboxl  s*    




zAxis.get_tightbboxc             C   sL   g }t | jƒr"| | jd  ¡ ¡ t | jƒr@| | jd  ¡ ¡ t|ddS )Nr   )rN   )r  r»   r½   r\   r¾   Úmax)rC   Úvaluesr	   r	   r
   r\   ‘  s    

zAxis.get_tick_paddingc             O   sž   |   ¡ sdS | t¡ |  |¡}|  ||¡\}}x|D ]}| |¡ q6W |  |¡ | j |¡ |  ||¡ | j	 
| jj ¡ ¡ | j	 |¡ | t¡ d| _dS )z6Draw the axis lines, grid lines, tick lines and labelsNF)ro   rp   r   r  r  rq   r1  r:   r2  rÔ   rt   r   r¸   r3  rr   r`   )rC   rs   Úargsræ   r  r  r  rÁ   r	   r	   r
   rq   ™  s    





z	Axis.drawc             C   s   t dƒ‚d S )NzDerived must override)rz   )rC   r	   r	   r
   rÑ   ¾  s    zAxis._get_labelc             C   s   t dƒ‚d S )NzDerived must override)rz   )rC   r	   r	   r
   rÓ   Á  s    zAxis._get_offset_textc             C   s   |   ¡ }t ddd„ |D ƒ¡S )z2Return the grid lines as a list of Line2D instancezLine2D gridlinec             S   s   g | ]
}|j ‘qS r	   )r7   )r   rÁ   r	   r	   r
   r   È  s    z&Axis.get_gridlines.<locals>.<listcomp>)rî   rÌ   Úsilent_list)rC   r.  r	   r	   r
   Úget_gridlinesÄ  s    zAxis.get_gridlinesc             C   s   | j S )z(Return the axis label as a Text instance)r:   )rC   r	   r	   r
   Ú	get_labelÊ  s    zAxis.get_labelc             C   s   | j S )z-Return the axis offsetText as a Text instance)rÔ   )rC   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Õ   )rC   r	   r	   r
   Úget_pickradiusÒ  s    zAxis.get_pickradiusc             C   s4   |   ¡ }dd„ |D ƒ}dd„ |D ƒ}t d|| ¡S )z8Return a list of Text instances for the major ticklabelsc             S   s   g | ]}|j r|j‘qS r	   )r@   r9   )r   rÁ   r	   r	   r
   r   Ù  s    z,Axis.get_majorticklabels.<locals>.<listcomp>c             S   s   g | ]}|j r|j‘qS r	   )rA   r<   )r   rÁ   r	   r	   r
   r   Ú  s    zText major ticklabel)rî   rÌ   r8  )rC   r.  Úlabels1Úlabels2r	   r	   r
   Úget_majorticklabelsÖ  s    zAxis.get_majorticklabelsc             C   s4   |   ¡ }dd„ |D ƒ}dd„ |D ƒ}t d|| ¡S )z8Return a list of Text instances for the minor ticklabelsc             S   s   g | ]}|j r|j‘qS r	   )r@   r9   )r   rÁ   r	   r	   r
   r   à  s    z,Axis.get_minorticklabels.<locals>.<listcomp>c             S   s   g | ]}|j r|j‘qS r	   )rA   r<   )r   rÁ   r	   r	   r
   r   á  s    zText minor ticklabel)rï   rÌ   r8  )rC   r.  r=  r>  r	   r	   r
   Úget_minorticklabelsÝ  s    zAxis.get_minorticklabelsc             C   sd   |dk	rP|dkr|   ¡ S |dkr(|  ¡ S |dkr@|  ¡ |   ¡  S tdt|ƒ ƒ‚|r\|   ¡ S |  ¡ S )aì  
        Get the tick labels as a list of :class:`~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 :class:`~matplotlib.text.Text` instances.
        Nr   r   r   z6`which` must be one of ('minor', 'major', 'both') not )r@  r?  rS   rQ   )rC   r   r§   r	   r	   r
   Úget_ticklabelsä  s    zAxis.get_ticklabelsc             C   s>   g }|   ¡ }x$|D ]}| |j¡ | |j¡ qW t d|¡S )z9Return the major tick lines as a list of Line2D instanceszLine2D ticklines)rî   r½   r3   r5   rÌ   r8  )rC   Úlinesr.  rÁ   r	   r	   r
   Úget_majorticklines  s    
zAxis.get_majorticklinesc             C   s>   g }|   ¡ }x$|D ]}| |j¡ | |j¡ qW t d|¡S )z9Return the minor tick lines as a list of Line2D instanceszLine2D ticklines)rï   r½   r3   r5   rÌ   r8  )rC   rB  r.  rÁ   r	   r	   r
   Úget_minorticklines  s    
zAxis.get_minorticklinesc             C   s   |r|   ¡ S |  ¡ S )z3Return the tick lines as a list of Line2D instances)rD  rC  )rC   r   r	   r	   r
   Úget_ticklines  s    zAxis.get_ticklinesc             C   s
   | j  ¡ S )zAGet the major tick locations in data coordinates as a numpy array)r   r·   )rC   r	   r	   r
   Úget_majorticklocs   s    zAxis.get_majorticklocsc             C   s
   | j  ¡ S )zAGet the minor tick locations in data coordinates as a numpy array)r   r·   )rC   r	   r	   r
   Úget_minorticklocs$  s    zAxis.get_minorticklocsc             C   s   |r| j  ¡ S | j ¡ S )z;Get the tick locations in data coordinates as a numpy array)r   r·   r   )rC   r   r	   r	   r
   Úget_ticklocs(  s    
zAxis.get_ticklocsc             C   s8   |rt  dd„ |  ¡ D ƒ¡S t  dd„ |  ¡ 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	   )rW   )r   rÁ   r	   r	   r
   r   ?  s    z,Axis.get_ticks_direction.<locals>.<listcomp>c             S   s   g | ]
}|j ‘qS r	   )rW   )r   rÁ   r	   r	   r
   r   B  s    N)r(  Zarrayrï   rî   )rC   r   r	   r	   r
   Úget_ticks_direction.  s
    zAxis.get_ticks_directionc             C   s   t dƒ‚dS )z return the default tick instancezderived must overrideN)rz   )rC   r   r	   r	   r
   r¼   D  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	|_	dS )z)Copy the props from src tick to dest tickN)
r9   Zupdate_fromr<   r3   r5   r7   r>   r?   r@   rA   )rC   ÚsrcÚdestr	   r	   r
   Ú_copy_tick_propsH  s    zAxis._copy_tick_propsc             C   s
   | j  ¡ S )zGet the text of the label)r:   Úget_text)rC   r	   r	   r
   Úget_label_textX  s    zAxis.get_label_textc             C   s   | j jS )z#Get the locator of the major ticker)r   r·   )rC   r	   r	   r
   Úget_major_locator\  s    zAxis.get_major_locatorc             C   s   | j jS )z#Get the locator of the minor ticker)r   r·   )rC   r	   r	   r
   Úget_minor_locator`  s    zAxis.get_minor_locatorc             C   s   | j jS )z%Get the formatter of the major ticker)r   r¸   )rC   r	   r	   r
   Úget_major_formatterd  s    zAxis.get_major_formatterc             C   s   | j jS )z%Get the formatter of the minor ticker)r   r¸   )rC   r	   r	   r
   Úget_minor_formatterh  s    zAxis.get_minor_formatterc             C   sn   |dkrt |  ¡ ƒ ƒ}xHt | jƒ|k r^| jdd}| j |¡ | jrJd|_|  | jd |¡ qW | jd|… S )z)get the tick instances; grow as necessaryNT)r   r   )r  rO  r»   r¼   r½   rò   r=   rL  )rC   ÚnumticksrÁ   r	   r	   r
   rî   l  s    zAxis.get_major_ticksc             C   sn   |dkrt |  ¡ ƒ ƒ}xHt | jƒ|k r^| jdd}| j |¡ | jrJd|_|  | jd |¡ qW | jd|… S )z/get the minor tick instances; grow as necessaryNF)r   Tr   )r  rP  r¾   r¼   r½   ró   r=   rL  )rC   rS  rÁ   r	   r	   r
   rï   {  s    zAxis.get_minor_ticksc             K   s¤   t |ƒrd}| ¡ }dd„ | ¡ D ƒ}|dkr`|dkrB| 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)

        Tc             S   s   i | ]}|d  d|d  “qS )r}   r   r   r	   )r   Úitemr	   r	   r
   r   £  s    zAxis.grid.<locals>.<dictcomp>)r   r   Nr   )r§   r=   )r   r   r   )r  r   r/   ró   rý   rò   r`   )rC   r0  r§   ræ   Zgridkwr	   r	   r
   r­   Š  s"    z	Axis.gridc             C   sh   t j |¡}|dkrdS | j|k}|| _| j || ¡}|dk	rR| jdkrR|  |¡ |r^|  ¡  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_axisinfor`   )rC   Údatarõ   ZneednewrN   r	   r	   r
   Úupdate_units´  s    

zAxis.update_unitsc             C   s  | j dkrdS | j  | j| ¡}|dkr*dS |jdk	rZ| jj|jkrZ| jrZ|  |j¡ d| _|jdk	rŠ| j	j|jkrŠ| j
rŠ|  |j¡ d| _
|jdk	rº| jj|jkrº| jrº|  |j¡ d| _|jdk	rê| j	j|jkrê| jrê|  |j¡ d| _|jdk	r| jr|  |j¡ d| _|  ¡  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  )rC   Úinfor	   r	   r
   rX  Ê  s2    




zAxis._update_axisinfoc             C   s   | j d k	p| jd k	S )N)rõ   rë   )rC   r	   r	   r
   Ú
have_unitsì  s    zAxis.have_unitsc             C   sL   t j |¡r|S | jd kr(t j |¡| _| jd kr6|S | j || j| ¡}|S )N)rU  ZConversionInterfaceZ
is_numlikerõ   rV  rW  Úconvertrë   )rC   r“   Úretr	   r	   r
   Úconvert_unitsï  s    

zAxis.convert_unitsc             C   sZ   d}|dkrd| _ d}n|| j kr,|| _ d}|rP|  ¡  | j d¡ | j d¡ d| _dS )zF
        set the units for axis

        ACCEPTS: a units tag
        FNTrë   zunits finalize)rë   rX  rÎ   Zprocessr`   )rC   ÚuZpchangedr	   r	   r
   rí   ý  s    
zAxis.set_unitsc             C   s   | j S )zreturn the units for axis)rë   )rC   r	   r	   r
   Ú	get_units  s    zAxis.get_unitsc             K   s>   d| _ | j |¡ |dk	r&| j |¡ | j |¡ d| _| jS )zf
        Set the text value of the axis label.

        ACCEPTS: A string value for the label
        FNT)rË   r:   rt   rú   r`   )rC   r:   Zfontdictræ   r	   r	   r
   r`    s    zAxis.set_label_textc             C   s6   t |tjƒstdƒ‚d| _|| 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)	rP   ÚmtickerÚ	FormatterÚ	TypeErrorrã   r   r¸   Úset_axisr`   )rC   r¸   r	   r	   r
   r^  #  s    
zAxis.set_major_formatterc             C   s6   t |tjƒstdƒ‚d| _|| 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)	rP   rh  ri  rj  rä   r   r¸   rk  r`   )rC   r¸   r	   r	   r
   r_  3  s    
zAxis.set_minor_formatterc             C   s6   t |tjƒstdƒ‚d| _|| j_| | ¡ d| _dS )zŠ
        Set the locator of the major ticker.

        Parameters
        ----------
        locator : ~matplotlib.ticker.Locator
        zBformatter argument should be instance of matplotlib.ticker.LocatorFTN)	rP   rh  ÚLocatorrj  rá   r   r·   rk  r`   )rC   r·   r	   r	   r
   r\  C  s    
zAxis.set_major_locatorc             C   s6   t |tjƒstdƒ‚d| _|| j_| | ¡ d| _dS )zŠ
        Set the locator of the minor ticker.

        Parameters
        ----------
        locator : ~matplotlib.ticker.Locator
        zBformatter argument should be instance of matplotlib.ticker.LocatorFTN)	rP   rh  rl  rj  râ   r   r·   rk  r`   )rC   r·   r	   r	   r
   r]  S  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Õ   )rC   rÕ   r	   r	   r
   Úset_pickradiusc  s    zAxis.set_pickradius)r   c         	   O   sø   g }x>|D ]6}y|  | ¡ ¡ W q
 tk
r>   |  |¡ Y q
X q
W |}|rf|  t |¡¡ |  ¡ }n|  t |¡¡ |  ¡ }g }xjt	||ƒD ]\\}	}
|
j
 |	¡ |
j
 |¡ |
j |	¡ |
j |¡ |
jrØ|  |
j
¡ |
jrŽ|  |
j¡ qŽW d| _|S )aÊ  
        Set the text values of the tick labels. Return a list of Text
        instances.  Use *kwarg* *minor=True* to select minor ticks.
        All other kwargs are used to update the text object properties.
        As for get_ticklabels, label1 (left or bottom) is
        affected for a given tick only if its label1On attribute
        is True, and similarly for label2.  The list of returned
        label text objects consists of all such label1 objects followed
        by all such label2 objects.

        The input *ticklabels* is assumed to match the set of
        tick locations, regardless of the state of label1On and
        label2On.

        ACCEPTS: sequence of strings or Text objects
        T)r½   rM  rö   r_  rh  ZFixedFormatterrï   r^  rî   r  r9   rt   rú   r<   r@   rA   r`   )rC   Z
ticklabelsr   r7  ræ   Z
get_labelsrž   r.  rd  Z
tick_labelrÁ   r	   r	   r
   Úset_ticklabelsm  s0    

zAxis.set_ticklabelsc             C   s˜   |   |¡}t|ƒdkrT|  ¡ \}}||kr@|  t|ƒt|ƒ¡ n|  t|ƒt|ƒ¡ |rv|  t |¡¡ |  	t|ƒ¡S |  
t |¡¡ |  t|ƒ¡S dS )zn
        Set the locations of the tick marks from sequence ticks

        ACCEPTS: sequence of floats
        r}   N)re  r  r{   r  Úminr5  r]  rh  ZFixedLocatorrï   r\  rî   )rC   r.  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)rz   )rC   Zxdirrs   r	   r	   r
   Ú_get_tick_boxes_siblings¶  s    zAxis._get_tick_boxes_siblingsc             C   s   t dƒ‚dS )zy
        Update the label position based on the bounding box enclosing
        all the ticklabels and axis spine
        zDerived must overrideN)rz   )rC   rs   r	   r	   r
   r1  ¿  s    zAxis._update_label_positionc             C   s   t dƒ‚dS )zq
        Update the label position based on the sequence of bounding
        boxes of all the ticklabels
        zDerived must overrideN)rz   )rC   ÚbboxesÚbboxes2r	   r	   r
   r2  Æ  s    z!Axis._update_offset_text_positionc             C   s   | j j |¡ dS )z,Pan *numsteps* (can be positive or negative)N)r   r·   Úpan)rC   Znumstepsr	   r	   r
   rt  Í  s    zAxis.panc             C   s   | j j |¡ dS )z@Zoom in/out on axis; if *direction* is >0 zoom in, else zoom outN)r   r·   Úzoom)rC   rÿ   r	   r	   r
   ru  Ñ  s    z	Axis.zoomc             C   s@   t |tƒrddl}|j |¡}|  t ddddddd|¡¡ dS )zÇ
        Sets up x-axis ticks and labels that treat the x data as dates.
        *tz* is a :class:`tzinfo` instance or a timezone string.
        This timezone is used to create date labels.
        r   NiÙ  r}   )rP   rQ   Zdateutil.tzÚtzZgettzrZ  Údatetime)rC   rv  Zdateutilr	   r	   r
   Ú	axis_dateÕ  s    	
zAxis.axis_datec             C   s
   t ƒ ‚dS )zP
        Return the estimated number of ticks that can fit on the axis.
        N)rz   )rC   r	   r	   r
   Úget_tick_spaceã  s    zAxis.get_tick_spacec             C   s   | j S )z;
        Return the label position (top or bottom)
        )Úlabel_position)rC   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)rz   )rC   Úpositionr	   r	   r
   Úset_label_positionð  s    zAxis.set_label_positionc             C   s
   t ƒ ‚d S )N)rz   )rC   r	   r	   r
   rè   ú  s    zAxis.get_minpos)rÉ   )N)r   F)T)N)F)FN)F)F)F)N)N)Nr   )N)F)N)]r   r   rŽ   r   ÚOFFSETTEXTPADrÈ   r   r¹   r»   r¾   rÜ   rÞ   rß   rÚ   rç   ÚpropertyrÌ   Z
deprecatedrì   Úsetterr^   rÙ   rô   rý   Ústaticmethodrø   r_   r{   r  r  r  r  ry   r  r  r   r!  r  r  r4  r\   r   rq   rÑ   rÓ   r9  r:  r;  r<  r?  r@  rA  rC  rD  rE  rF  rG  rH  rI  r¼   rL  rN  rO  rP  rQ  rR  rî   rï   r­   rZ  rX  rb  re  rí   rg  r`  r^  r_  r\  r]  rm  rn  rp  rq  r1  r2  rt  ru  rx  ry  r{  r}  rè   r	   r	   r	   r
   rÃ   ¯  s®   
!


		
3

c%%
$		





*"

4
	

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dd „ Zd/d"d#„Zd$d%„ Zd&d'„ Zd0d(d)„Zd*d+„ Zd,d-„ Zd.S )1ÚXAxisÚxaxisr“   c             C   sà   t | jƒr|  | |¡S |j|j }}y"| jj ¡ }| ||f¡\}}W n tk
r^   di fS X | jj d¡\}}| 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.
        F)r   r   )r}   r}   r   r}   )
rf   rg   r“   r”   r   rÆ   ÚinvertedrÇ   rS   rÕ   )rC   rh   r“   r”   r‹   ÚxaxesÚyaxesr©   r0  Úrrž   Úinaxisr	   r	   r
   ri     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   )rC   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	}| t | jj	t 
¡ ¡¡ |  |¡ d
| _|S )Ng      à?r   zaxes.labelsizezaxes.labelweight)rE   Úweightzaxes.labelcolorr  Úcenter)r“   r”   r•   rG   r–   r—   r  )r˜   r™   rš   r›   r   r†   r  Úblended_transform_factoryr   rÆ   ÚIdentityTransformry   rz  )rC   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}| t | jj	t 
¡ ¡¡ |  |¡ d	| _|S )
Nr}   r   zxtick.labelsize)rE   zxtick.colorr  r  )r“   r”   r•   rG   r–   r—   r  )r˜   r™   rš   r›   r   r†   r  r‹  r   rÆ   rŒ  ry   Úoffset_text_position)rC   rÔ   r	   r	   r
   rÓ   .  s    

zXAxis._get_offset_textc             C   s\   | j jdkrdS | j j}| ¡ }| |df¡}| |d | |d f¡}t|d | ƒ}|S )aÌ  
        Returns the amount, in data coordinates, that a single pixel
        corresponds to in the locality given by "where", which is also given
        in data coordinates, and is an x coordinate. "perturb" is the amount
        to perturb the pixel.  Usually +0.5 or -0.5.

        Implementing this routine for an axis is optional; if present, it will
        ensure that no ticks are lost due to round-off at the extreme ends of
        an axis.
        Zpolarg        g»½×Ùß|Û=r   r}   )r   r   Ú	transDatar„  rÇ   Úabs)rC   ÚwhereÚperturbr‹   ÚtransinvÚpixÚptpZdxr	   r	   r
   r&  =  s    z$XAxis._get_pixel_distance_along_axisc             C   sD   |dkr| j  d¡ n|dkr,| 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_verticalalignmentrS   rz  r`   )rC   r|  r	   r	   r
   r}  `  s    zXAxis.set_label_positionc       
      C   sh   g }g }| j j}xNt| | j¡ƒD ]:\}}|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_grpr  Úget_siblingsr   rƒ  r  r  rð   )
rC   rs   rr  rs  ÚgrpZnnÚaxxr  ÚtlbÚtlb2r	   r	   r
   rq  q  s    
zXAxis._get_tick_boxes_siblingsc             C   s4  | j s
dS | j|d\}}| j ¡ \}}| jdkr²y&| jjd }| ¡  | 	¡ ¡ 
¡ }W n tk
rt   | jj}Y nX tj ||g ¡}|j}	| j ||	| j| jj d  f¡ n~y&| jjd }| ¡  | 	¡ ¡ 
¡ }W n tk
rô   | jj}Y nX tj ||g ¡}|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)rs   r  rc   r  )rÏ   rq  r:   Úget_positionrz  r   ÚspinesrÞ   Útransform_pathr¯   Úget_extentsÚKeyErrorr  r  r  r  Úy0rÛ   rÒ   r   rd   Zy1)rC   rs   rr  rs  r“   r”   ÚspineÚ	spinebboxr  r  r  r	   r	   r
   r1  „  s2    
zXAxis._update_label_positionc             C   sZ   | j  ¡ \}}t|ƒs"| jjj}nt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
        rc   N)rÔ   rœ  r  r   r  Úyminr  r  r  r¡  rÛ   r~  r   rd   )rC   rr  rs  r“   r”   r  r  r	   r	   r
   r2  ¯  s    z"XAxis._update_offset_text_positionc             C   sŽ   |   |¡\}}| jd  ¡ }d}|jr4||j| 7 }d}|jrL||j| 7 }|  ¡ dkrp|| j |¡j| 7 }n|| 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  )r  r»   re   r/  r{  r:   r-  )rC   rs   r  r  Ú	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  ÚnonerN   zinvalid position: %sN)rý   rS   r`   )rC   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 }|  d¡ | jd|d dS )zP
        Move ticks and ticklabels (if present) to the top of the axes.
        Tr@   rA   r  r   )r§   r  N)r×   r¨  rý   )rC   r:   r	   r	   r
   Útick_topô  s    



zXAxis.tick_topc             C   s>   d}d| j kr"| j d p | j d }|  d¡ | jd|d dS )zS
        Move ticks and ticklabels (if present) to the bottom of the axes.
        Tr@   rA   r  r   )r§   r  N)r×   r¨  rý   )rC   r:   r	   r	   r
   Útick_bottom  s    



zXAxis.tick_bottomc       	      C   sà   | j d }| jd }|j o.|jo.|j o.|j}|j oJ|joJ|j oJ|j}|rX|rXdS |jor|j or|jor|j }|joŽ|j oŽ|joŽ|j }|rœ|rœdS |jo´|jo´|jo´|j }|joÎ|joÎ|joÎ|j }|rÜ|rÜdS dS )zM
        Return the ticks position (top, bottom, default or unknown)
        r   r  r  rN   Úunknown)r»   r¾   r>   r?   r@   rA   )	rC   ÚmajtÚmTZmajorTopZminorTopZMajorBottomZMinorBottomÚmajorDefaultÚminorDefaultr	   r	   r
   Úget_ticks_position  s*    

zXAxis.get_ticks_positionc             C   s
   | j jjS )z6return the Interval instance for this axis view limits)r   r±   r²   )rC   r	   r	   r
   r{   ,  s    zXAxis.get_view_intervalFc             C   sj   |r||f| j j_nR|  ¡ \}}||k rHt|||ƒt|||ƒf| j j_nt|||ƒt|||ƒf| j j_dS )aU  
        If *ignore* is *False*, the order of vmin, vmax
        does not matter; the original axis orientation will
        be preserved. In addition, the view limits can be
        expanded, but will not be reduced.  This method is
        for mpl internal use; for normal use, see
        :meth:`~matplotlib.axes.Axes.set_xlim`.

        N)r   r±   r²   r{   ro  r5  )rC   ré   rê   r
  ÚVminÚVmaxr	   r	   r
   r  0  s    


zXAxis.set_view_intervalc             C   s
   | j jjS )N)r   ÚdataLimZminposx)rC   r	   r	   r
   rè   E  s    zXAxis.get_minposc             C   s
   | j jjS )z6return the Interval instance for this axis data limits)r   r³  r²   )rC   r	   r	   r
   r  H  s    zXAxis.get_data_intervalc             C   sD   |r||f| j j_n&|  ¡ \}}t||ƒt||ƒf| j j_d| _dS )zset the axis data limitsTN)r   r³  r²   r  ro  r5  r`   )rC   ré   rê   r
  r±  r²  r	   r	   r
   r  L  s
    zXAxis.set_data_intervalc             C   s¨   d\}}| j j ¡ }| j j ¡ }|r(|sž| jdk	rz| j | j| ¡}|jdk	rz|j\}}| j || j| ¡}| j || j| ¡}|sŒ||f| j j_	|sž||f| j j_	d| _
dS )zDset the default limits for the axis interval if they are not mutated)g        g      ð?NT)r   r³  Zmutatedxr±   rõ   r[  rë   Údefault_limitsrc  r²   r`   )rC   ZxminZxmaxÚdataMutatedÚviewMutatedra  ÚvalminÚvalmaxr	   r	   r
   r  U  s    


zXAxis.set_default_intervalsc             C   sz   | j j ddgddgg¡}|d d |d d  | j jj d }|  d¡}|j ¡ d }|dkrrtt	 
|| ¡ƒS dS d S )Nr   r}   rc   TrÄ   iÿÿÿ)r   rÆ   rb   r   rd   r¼   r9   Úget_sizeÚintr(  Úfloor)rC   Úendsrþ   rÁ   rE   r	   r	   r
   ry  g  s    &
zXAxis.get_tick_spaceN)F)F)r   r   rŽ   Ú	axis_nameri   r¼   rÑ   rÓ   r&  r}  rq  r1  r2  r¦  r¨  r©  rª  r°  r{   r  rè   r  r  r  ry  r	   r	   r	   r
   r‚  þ  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dd „ Zd!d"„ Zd1d$d%„Zd&d'„ Zd(d)„ Zd2d*d+„Zd,d-„ Zd.d/„ Zd0S )3ÚYAxisÚyaxisr”   c             C   sà   t | jƒr|  | |¡S |j|j }}y"| jj ¡ }| ||f¡\}}W n tk
r^   di fS X | jj d¡\}}| 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*
        F)r   r   )r}   r}   r   r}   )
rf   rg   r“   r”   r   rÆ   r„  rÇ   rS   rÕ   )rC   rh   r“   r”   r‹   r…  r†  r©   r0  r‡  rž   rˆ  r	   r	   r
   ri   x  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   )rC   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}| t t ¡ | j	j
¡¡ |  |¡ d| _|S )Nr   g      à?zaxes.labelsizezaxes.labelweight)rE   r‰  zaxes.labelcolorr  rŠ  ZverticalÚanchor)r“   r”   r•   rG   r–   r—   r   Zrotation_moder   )r˜   r™   rš   r›   r   r†   r  r‹  rŒ  r   rÆ   ry   rz  )rC   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}| t | jj	t 
¡ ¡¡ |  |¡ d| _|S )	Nr   g      à?zytick.labelsize)rE   zytick.colorr•  r   )r“   r”   r•   rG   r–   r—   )r˜   r™   rš   r›   r   r†   r  r‹  r   rÆ   rŒ  ry   r  )rC   rÔ   r	   r	   r
   rÓ   ¨  s    

zYAxis._get_offset_textc             C   sL   | j j}| ¡ }| d|f¡}| |d |d | f¡}t|d | ƒ}|S )aÌ  
        Returns the amount, in data coordinates, that a single pixel
        corresponds to in the locality given by *where*, which is also given
        in data coordinates, and is a y coordinate.

        *perturb* is the amount to perturb the pixel.  Usually +0.5 or -0.5.

        Implementing this routine for an axis is optional; if present, it will
        ensure that no ticks are lost due to round-off at the extreme ends of
        an axis.
        g»½×Ùß|Û=r   r}   )r   rŽ  r„  rÇ   r  )rC   r  r‘  r‹   r’  r“  r”  Zdyr	   r	   r
   r&  ¸  s    z$YAxis._get_pixel_distance_along_axisc             C   s\   | j  d¡ | j  d¡ |dkr.| j  d¡ n|dkrD| 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–  rS   rz  r`   )rC   r|  r	   r	   r
   r}  Ó  s    zYAxis.set_label_positionc       	      C   s`   g }g }| j j}xF| | j¡D ]6}|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¿  r  r  rð   )	rC   rs   rr  rs  r˜  r™  r  rš  r›  r	   r	   r
   rq  æ  s    
zYAxis._get_tick_boxes_siblingsc             C   s4  | j s
dS | j|d\}}| j ¡ \}}| jdkr²y&| jjd }| ¡  | 	¡ ¡ 
¡ }W n tk
rt   | jj}Y nX tj ||g ¡}|j}	| j |	| j| jj d  |f¡ n~y&| jjd }| ¡  | 	¡ ¡ 
¡ }W n tk
rô   | jj}Y nX tj ||g ¡}|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)rs   r   rc   r  )rÏ   rq  r:   rœ  rz  r   r  rÞ   rž  r¯   rŸ  r   r  r  r  r  Zx0rÛ   rÒ   r   rd   Zx1)rC   rs   rr  rs  r“   r”   r¢  r£  r  r   r  r	   r	   r
   r1  ù  s2    
zYAxis._update_label_positionc             C   s>   | 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
        rc   N)	rÔ   rœ  r   r  ÚymaxrÛ   r~  r   rd   )rC   rr  rs  r“   r”   r  r	   r	   r
   r2  #	  s    
z"YAxis._update_offset_text_positionc             C   sX   | j  ¡ \}}|dkrd}n|dkr*d}ntdƒ‚| j  |¡ | j  ||f¡ d| _dS )zT
        Parameters
        ----------
        position : {'left', 'right'}
        r   r   r  r}   z*Position accepts only [ 'left' | 'right' ]TN)rÔ   rœ  rS   Zset_harÛ   r`   )rC   r|  r“   r”   r	   r	   r
   Úset_offset_position.	  s    zYAxis.set_offset_positionc             C   sŽ   |   |¡\}}| jd  ¡ }d}|jr4||j| 7 }d}|jrL||j| 7 }|  ¡ dkrp|| j |¡j| 7 }n|| j |¡j| 7 }||fS )Nr   g        r   )r  r»   re   rF   r{  r:   r-  )rC   rs   r  r  r¥  r   r  r	   r	   r
   Úget_text_widths@	  s    zYAxis.get_text_widthsc             C   s¸   |dkr(| j dddddd |  |¡ n†|dkrP| j dddddd |  |¡ 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§  rN   zinvalid position: %sN)rý   rÂ  rS   r`   )rC   r|  r	   r	   r
   r¨  R	  s&    






zYAxis.set_ticks_positionc             C   s>   d}d| j kr"| j d p | j d }|  d¡ | jd|d dS )zR
        Move ticks and ticklabels (if present) to the right of the axes.
        Tr@   rA   r  r   )r§   r  N)r×   r¨  rý   )rC   r:   r	   r	   r
   Ú
tick_rightt	  s    



zYAxis.tick_rightc             C   s>   d}d| j kr"| j d p | j d }|  d¡ | jd|d dS )zQ
        Move ticks and ticklabels (if present) to the left of the axes.
        Tr@   rA   r   r   )r§   r  N)r×   r¨  rý   )rC   r:   r	   r	   r
   Ú	tick_left	  s    



zYAxis.tick_leftc       	      C   sà   | j d }| jd }|j o.|jo.|j o.|j}|j oJ|joJ|j oJ|j}|rX|rXdS |jor|j or|jor|j }|joŽ|j oŽ|joŽ|j }|rœ|rœdS |jo´|jo´|jo´|j }|joÎ|joÎ|joÎ|j }|rÜ|rÜdS dS )zJ
        Return the ticks position (left, right, both or unknown)
        r   r  r   rN   r«  )r»   r¾   r>   r?   r@   rA   )	rC   r¬  r­  Z
majorRightZ
minorRightZ	majorLeftZ	minorLeftr®  r¯  r	   r	   r
   r°  Ž	  s*    

zYAxis.get_ticks_positionc             C   s
   | j jjS )z6return the Interval instance for this axis view limits)r   r±   rµ   )rC   r	   r	   r
   r{   ¬	  s    zYAxis.get_view_intervalFc             C   sp   |r||f| j j_nR|  ¡ \}}||k rHt|||ƒt|||ƒf| j j_nt|||ƒt|||ƒf| j j_d| _dS )aU  
        If *ignore* is *False*, the order of vmin, vmax
        does not matter; the original axis orientation will
        be preserved. In addition, the view limits can be
        expanded, but will not be reduced.  This method is
        for mpl internal use; for normal use, see
        :meth:`~matplotlib.axes.Axes.set_ylim`.

        TN)r   r±   rµ   r{   ro  r5  r`   )rC   ré   rê   r
  r±  r²  r	   r	   r
   r  °	  s    


zYAxis.set_view_intervalc             C   s
   | j jjS )N)r   r³  Zminposy)rC   r	   r	   r
   rè   Æ	  s    zYAxis.get_minposc             C   s
   | j jjS )z6return the Interval instance for this axis data limits)r   r³  rµ   )rC   r	   r	   r
   r  É	  s    zYAxis.get_data_intervalc             C   sD   |r||f| j j_n&|  ¡ \}}t||ƒt||ƒf| j j_d| _dS )zset the axis data limitsTN)r   r³  rµ   r  ro  r5  r`   )rC   ré   rê   r
  r±  r²  r	   r	   r
   r  Í	  s
    zYAxis.set_data_intervalc             C   s¨   d\}}| j j ¡ }| j j ¡ }|r(|sž| jdk	rz| j | j| ¡}|jdk	rz|j\}}| j || j| ¡}| j || j| ¡}|sŒ||f| j j_	|sž||f| j j_	d| _
dS )zDset the default limits for the axis interval if they are not mutated)g        g      ð?NT)r   r³  Zmutatedyr±   rõ   r[  rë   r´  rc  rµ   r`   )rC   r¤  rÁ  rµ  r¶  ra  r·  r¸  r	   r	   r
   r  Ö	  s    


zYAxis.set_default_intervalsc             C   sz   | j j ddgddgg¡}|d d |d d  | j jj d }|  d¡}|j ¡ d }|dkrrtt	 
|| ¡ƒS dS d S )Nr   r}   rc   Tg       @iÿÿÿ)r   rÆ   rb   r   rd   r¼   r9   r¹  rº  r(  r»  )rC   r¼  rþ   rÁ   rE   r	   r	   r
   ry  è	  s    &
zYAxis.get_tick_spaceN)F)F)r   r   rŽ   r½  ri   r¼   rÑ   rÓ   r&  r}  rq  r1  r2  rÂ  rÃ  r¨  rÄ  rÅ  r°  r{   r  rè   r  r  r  ry  r	   r	   r	   r
   r¾  t  s0   *"

	r¾  )<r   rw  Zloggingr+  Znumpyr(  Z
matplotlibr   Zmatplotlib.artistr   r   Zmatplotlib.cbookrÌ   r   Zmatplotlib.font_managerrš   Zmatplotlib.linesrB  r'   Zmatplotlib.patchesZpatchesZmpatchesZmatplotlib.scaleZscalerà   Zmatplotlib.textÚtextr˜   Zmatplotlib.tickerZtickerrh  Zmatplotlib.transformsZ
transformsr  Zmatplotlib.unitsrë   rU  Z	getLoggerr   Z_logr®   ZArtistInspectorr(   Z_line_AIZget_settersZ_line_param_namesZaliasdr6  Z_line_param_aliasesr€   r   r   r   r³   Úobjectr¶   r¹   rÃ   r‚  r¾  r	   r	   r	   r
   Ú<module>   sX   
  p{{         W  x