3
ƽhi                @   sP  d Z ddlZddlZddlZddlZddl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-Z/G dd dZ0G dd dZ1G dd de
j,Z2dd Z3G dd de2Z4G dd de2Z5dS )z)
Classes for the ticks and x and y axis.
    N   c             C   s   g | ]}t |d  qS )r   )list).0d r   5/tmp/pip-build-7iwl8md4/matplotlib/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ejdddC fdd		Z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dDd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jd/d0 Zd1d2 ZeZd3d4 Z fd5d6Z d7d8 Z!d9d: Z"d;d< Z#d=d> Z$d?d@ Z%dAdB Z&  Z'S )E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.

    z3.3labelNTFr   c                s  t jj|  |dkrV|r2tjd d)kr2tjd }n$| rRtjd d*krRtjd }nd}| j|j || _| jj	 }|| _
|| _|rdnd}|dkrtj| d| d	 }|| _|dkrtj| d| d
 }|| _|dkrtj| d }|dkr
tj| d| d }|| _|
dkr*tj| d }
|	dkrDtj| d }	| j| |dkrt|rltjjd }ntjj}|| _|dkrtjd }|dkrtjd }|dkrtjd }|dkrtjd }dd |j D }| j| tjg g |d|||||d	| _tjg g |d|||||d	| _tjg g f|||||dd|| _t| jj _tjtjtj|	|
|d| _ tjtjtj|	|
|d| _!xLd0D ]D\}}t"j#t$ || d$d%| d&| d'd(}|rt%| ||  qW x,| j| j| j| j | j!gD ]}| j&| qW | j'| dS )1z
        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minorF.z.sizez.widthz.colorz.padz
.labelsizeg{Gz?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>none)color	linestylezordervisiblemarkeredgecolorZ
markersizeZmarkeredgewidth )r   alphar   r   Z	linewidthmarker)fontsizer   r   _get_tick1line	tick1line_get_tick2line	tick2line_get_gridlinegridline
_get_text1label1
_get_text2label2z3.3zRelying on z to initialize Tick.z is deprecated since %(since)s and will not work %(removal)s; please directly set the attribute in the subclass' __init__ instead.)Zsincemessage)r   r   )r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   )r*   r+   r,   r-   r.   )(martistArtist__init__mplrcParams
set_figurefigureaxes__name__lower_loc_major_size_width	_base_pad_set_labelrotationmlinesLine2Dr   Z_zorderitemsapply_tickdirr    r"   r$   GRIDLINE_INTERPOLATION_STEPSget_pathZ_interpolation_stepsmtextTextnpnanr&   r(   cbookZ_deprecate_method_overridegetattrsetattr_set_artist_propsupdate_position)selfr6   locr   sizewidthr   tickdirpad	labelsize
labelcolorr   gridOntick1Ontick2Onlabel1Onlabel2Onr   labelrotationZ
grid_colorZgrid_linestyleZgrid_linewidthZ
grid_alphakwr
   Zmajor_minorgrid_kwmethattrZoverridden_methodartist)	__class__r   r   r1   8   s    
















   "zTick.__init__z3.1zTick.label1)alternativependingc             C   s   | j S )N)r&   )rN   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)r[   )
isinstancestrtupler   rI   _check_in_list_labelrotation)rN   r[   modeZangler   r   r   r>      s    

zTick._set_labelrotationc             C   s   dS )z2Calculate ``self._pad`` and ``self._tickmarkers``.Nr   )rN   rR   r   r   r   rB      s    zTick.apply_tickdirc             C   s   | j S )N)_tickdir)rN   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;   rl   )rN   paddingr   r   r   get_tick_padding   s    zTick.get_tick_paddingc             C   s   | j | j| j| j| jg}|S )N)r    r"   r$   r&   r(   )rN   childrenr   r   r   get_children   s    zTick.get_childrenc             C   s(   t jj| || | jj|| d| _d S )NT)r/   r0   set_clip_pathr$   stale)rN   clippath	transformr   r   r   ru      s    zTick.set_clip_pathc             C   s   | j j| j d S )NH   )r5   dpir=   )rN   r   r   r   get_pad_pixels   s    zTick.get_pad_pixelsc             C   s&   | j |\}}|dk	r||f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)_default_contains)rN   
mouseeventinsideinfor   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
        )rS   TN)_apply_paramsrv   )rN   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=   )rN   r   r   r   get_pad  s    zTick.get_padc             C   s   dS )z Get the default Text 1 instance.Nr   )rN   r   r   r   r%     s    zTick._get_text1c             C   s   dS )z Get the default Text 2 instance.Nr   )rN   r   r   r   r'     s    zTick._get_text2c             C   s   dS )z*Get the default line2D instance for tick1.Nr   )rN   r   r   r   r     s    zTick._get_tick1linec             C   s   dS )z*Get the default line2D instance for tick2.Nr   )rN   r   r   r   r!     s    zTick._get_tick2linec             C   s   dS )z3Get the default grid Line2d instance for this tick.Nr   )rN   r   r   r   r#     s    zTick._get_gridlinec             C   s   | j S )z3Return the tick location (data coords) as a scalar.)r9   )rN   r   r   r   get_loc  s    zTick.get_locc             C   sh   | j  sd| _d S |j| j| j d x*| j| j| j| j| j	gD ]}|j
| q@W |j| j d| _d S )NF)gid)get_visiblerv   
open_groupr7   get_gidr$   r    r"   r&   r(   drawclose_group)rN   rendererr`   r   r   r   r     s    z	Tick.drawc             C   s   | j j| d| _dS )z]
        Set the label1 text.

        Parameters
        ----------
        s : str
        TN)r&   set_textrv   )rN   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)r(   r   rv   )rN   r   r   r   r   
set_label24  s    zTick.set_label2c                s.   t  j| | jj| | jj| d| _dS )zl
        Set the url of label1 and label2.

        Parameters
        ----------
        url : str
        TN)superset_urlr&   r(   rv   )rN   url)ra   r   r   r   ?  s    zTick.set_urlc             C   s   |j | j d S )N)r4   r5   )rN   ar   r   r   rL   L  s    zTick._set_artist_propsc             C   s   t ddS )zX
        Return the view limits ``(min, max)`` of the axis the tick belongs to.
        zDerived must overrideN)NotImplementedError)rN   r   r   r   get_view_intervalO  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	 qW | j d }| jj| | j d }| jj| dd  j D }d krX d |d< | jjf | | jjf | x&|j D ]\}}t| d| | q~W 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| | qpW d S )NrV   rW   rX   rY   rZ   c             3   s   | ]}| kV  qd S )Nr   )r   r   )r\   r   r   	<genexpr>]  s    z%Tick._apply_params.<locals>.<genexpr>rP   rQ   rS   rR   r      c             S   s   i | ]\}}|dkr||qS )r   r   )r   r   r   )r   r   r   r   r   r   r   p  s    z&Tick._apply_params.<locals>.<dictcomp>r   r   _r[   )rotationc             S   s&   i | ]\}}|dkr||dd qS )rT   rU   r   N)rT   rU   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_)rP   rQ   rS   rR   )r$   r    r"   r&   r(   set_visiblepopanyr;   r<   r=   rB   rl   Z
set_marker_tickmarkersZset_markersizeZset_markeredgewidth_get_text1_transformset_transform_get_text2_transformrA   setrK   r>   rj   rJ   )rN   r\   r
   targetlinetranstick_kwr   r   Zlabel_kwr]   r   )r\   r   r   U  sT    


zTick._apply_paramsc             C   s   t ddS )z:Set the location of tick in data coords with scalar *loc*.zDerived must overrideN)r   )rN   rO   r   r   r   rM     s    zTick.update_positionc             C   s   t dd S )NzDerived must override)r   )rN   r   r   r   r     s    zTick._get_text1_transformc             C   s   t dd S )NzDerived must override)r   )rN   r   r   r   r     s    zTick._get_text2_transform)NNNNNNNNNNTTTFTr   NNNN)N)(r7   
__module____qualname____doc__rI   Z_delete_parameterr1   property
deprecatedr   r>   rB   rm   rr   rt   ru   r{   r   r   r   r%   r'   r   r!   r#   r   r/   allow_rasterizationr   r   Z	set_labelr   r   rL   r   r   rM   r   r   __classcell__r   r   )ra   r   r   "   sf   
                   r	
9r   c                   sL   e Zd ZdZdZ  fddZdd Zdd Zd	d
 Zdd Zdd Z	  Z
S )XTickzq
    Contains all the Artists needed to make an x tick - the tick line,
    the label text and the grid line
    Zxtickc                s   t  j|| | jjdgdg| jjdd| jd d | jjdgdg| jjdd| jd d | jjddgddg| jjddd | j	 \}}}| j
jdd|||d	 | j \}}}| jjdd|||d	 d S )
Nr   tick1)which)xdataydatarx   r   r   tick2grid)r   r   rx   )xyverticalalignmenthorizontalalignmentrx   )r   r1   r    r   r6   Zget_xaxis_transformr   r"   r$   r   r&   r   r(   )rN   argskwargsr   vaha)ra   r   r   r1     s(    zXTick.__init__c             C   s   | j j| jS )N)r6   Zget_xaxis_text1_transform_pad)rN   r   r   r   r     s    zXTick._get_text1_transformc             C   s   | j j| jS )N)r6   Zget_xaxis_text2_transformr   )rN   r   r   r   r     s    zXTick._get_text2_transformc             C   s   |dkrt jd| jj   }tjdddg|d || _| jdkrPtjtj	f| _
n | jdkrbd	| _
ntj	tjf| _
| j| j  | _d| _dS )
z:Set tick direction. Valid values are 'in', 'out', 'inout'.Nz%s.directionrn   rp   ro   )rR   |T)r   r   )r2   r3   r7   r8   rI   ri   rl   r?   ZTICKUPZTICKDOWNr   r=   rr   r   rv   )rN   rR   r   r   r   rB     s    

zXTick.apply_tickdirc             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)	r    Z	set_xdatar"   r$   r&   Zset_xr(   r9   rv   )rN   rO   r   r   r   rM     s    zXTick.update_positionc             C   s
   | j jjS )N)r6   viewLim	intervalx)rN   r   r   r   r     s    zXTick.get_view_interval)r7   r   r   r   r1   r   r   rB   rM   r   r   r   r   )ra   r   r     s   
r   c                   sL   e Zd ZdZdZ  fddZdd Zdd Zd	d
 Zdd Zdd Z	  Z
S )YTickzp
    Contains all the Artists needed to make a Y tick - the tick line,
    the label text and the grid line
    Zytickc                s   t  j|| | jjdgdg| jjdd| jd d | jjdgdg| jjdd| jd d | jjddgddg| jjddd | j	 \}}}| j
jdd|||d	 | j \}}}| jjdd|||d	 d S )
Nr   r   )r   )r   r   rx   r   r   r   r   )r   r   rx   )r   r   r   r   rx   )r   r1   r    r   r6   Zget_yaxis_transformr   r"   r$   r   r&   r   r(   )rN   r   r   r   r   r   )ra   r   r   r1     s(    zYTick.__init__c             C   s   | j j| jS )N)r6   Zget_yaxis_text1_transformr   )rN   r   r   r   r     s    zYTick._get_text1_transformc             C   s   | j j| jS )N)r6   Zget_yaxis_text2_transformr   )rN   r   r   r   r   	  s    zYTick._get_text2_transformc             C   sv   |d krt jd| jj   }|| _| jdkr<tjtjf| _n | jdkrNd| _ntjtjf| _| j	| j
  | _d| _d S )Nz%s.directionrn   ro   r   T)r   r   )r2   r3   r7   r8   rl   r?   Z	TICKRIGHTZTICKLEFTr   r=   rr   r   rv   )rN   rR   r   r   r   rB     s    

zYTick.apply_tickdirc             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)	r    Z	set_ydatar"   r$   r&   Zset_yr(   r9   rv   )rN   rO   r   r   r   rM     s    zYTick.update_positionc             C   s
   | j jjS )N)r6   r   	intervaly)rN   r   r   r   r   $  s    zYTick.get_view_interval)r7   r   r   r   r1   r   r   rB   rM   r   r   r   r   )ra   r   r     s   
r   c               @   sL   e Zd ZdZdd Zedd Zejdd Zedd Zejd	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.
    c             C   s   d | _ d | _d S )N)_locator
_formatter)rN   r   r   r   r1   5  s    zTicker.__init__c             C   s   | j S )N)r   )rN   r   r   r   locator9  s    zTicker.locatorc             C   s$   t |tjstjddd || _d S )Nz3.2zSupport for locators that do not subclass matplotlib.ticker.Locator is deprecated since %(since)s and support for them will be removed %(removal)s.)r)   )rf   mtickerLocatorrI   warn_deprecatedr   )rN   r   r   r   r   r   =  s    
c             C   s   | j S )N)r   )rN   r   r   r   	formatterF  s    zTicker.formatterc             C   s$   t |tjstjddd || _d S )Nz3.2zSupport for formatters that do not subclass matplotlib.ticker.Formatter is deprecated since %(since)s and support for them will be removed %(removal)s.)r)   )rf   r   	FormatterrI   r   r   )rN   r   r   r   r   r   J  s    
N)	r7   r   r   r   r1   r   r   setterr   r   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)r:   )rN   r   r   r   r   r1   \  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)rN   instanceclstickr   r   r   __get___  s    z_LazyTickList.__get__N)r7   r   r   r   r1   r   r   r   r   r   r   T  s   r   c               @   s^  e Zd ZdZdZdd ZdddZedd	Zed
d	Z	dd Z
dd Zee
eddZdddZdd Zdd Zdd Zdd Zdd Zdd Zd d! Zdd#d$Zed%d& Zdd'd(Zd)d* Zdd+d,Zd-d. Zdd/d0Zd1d2 Zd3d4 Zd5d6 Z d7d8 Z!d9d: Z"e#j$d;d<d= Z%e#j$d;d>d? Z&d@dA Z'dBdC Z(d
dDdEdFZ)dGdH Z*e+j,dIdJ Z-dKdL Z.dMdN Z/dOdP Z0dQdR Z1dSdT Z2dUdV Z3ddWdXZ4dYdZ Z5d[d\ Z6dd]d^Z7d_d` Z8dadb Z9e#j:dcddddedfZ;ddgdhZ<didj Z=dkdl Z>dmdn Z?dodp Z@dqdr ZAdsdt ZBdudv ZCdwdx ZDddydzZEdd{d|ZFdd}d~ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdddZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTedd ZUd
dddZVe#j:dcddddZWe#j:d;dddddZXdd ZYdd ZZdd Z[e#j$dcdd Z\e#j$dcdd Z]dddZ^dd Z_dd Z`dd Zadd Zbdd Zcd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    dj t| jf| jjjd S )Nz	{}({},{})r   )r   r   )formattyper7   r6   	transAxesrx   )rN   r   r   r   __str__  s    zAxis.__str__   c             C   s   t jj|  d| _| j|j d| _|| _t | _	t | _
tj | _d| _d| _tjtjtjtjd tjd tjd d| _| j| j tjtjtj| _| j| j tjd | _|| _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.labelsizezaxes.labelweightzaxes.labelcolor)r   Z
fontweightr   zaxes.labelpadlinearN) r/   r0   r1   _remove_overlapping_locsr4   r5   isDefault_labelr6   r   r   r   rI   CallbackRegistry	callbacks_autolabelpos_smart_boundsrE   rF   rG   rH   r2   r3   r   rL   
offsetTextlabelpad
pickradiusdict_major_tick_kw_minor_tick_kwcla
_set_scale)rN   r6   r   r   r   r   r1     s0    

zAxis.__init__T)r   Fc             C   s   | j S )N)r   )rN   r   r   r   get_remove_overlapping_locs  s    z Axis.get_remove_overlapping_locsc             C   s   t || _d S )N)boolr   )rN   r   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 and the y coordinate of the
        x label are determined by the tick label bounding boxes, but this can
        lead to poor alignment of multiple labels if there are multiple axes.

        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 bottom left, (0.5, 0.5) is center, etc.
        FNT)r   r6   r   r   r   set_positionrv   )rN   r   r   rx   r   r   r   set_label_coords  s    zAxis.set_label_coordsc             C   s
   | j j S )N)_scaleget_transform)rN   r   r   r   r     s    zAxis.get_transformc             C   s   | j jS )z#Return this Axis' scale (as a str).)r   r
   )rN   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)rN   valuer   r   r   r   r     s    zAxis._set_scalec             C   s   | j j||| j S )N)r   limit_range_for_scale
get_minpos)rN   vminvmaxr   r   r   r     s    zAxis.limit_range_for_scalec             C   s   | j | jf| j | j S )N)r   r   get_major_ticksget_minor_ticks)rN   r   r   r   rt     s    
zAxis.get_childrenc             C   s   | j jd | jd tj | _tjd o6tjd dk| jd< tjd oTtjd dk| j	d< | j
  d	| _d	| _| jd	 d
| _d	S )zClear this axis.r   r   z	axes.gridzaxes.grid.whichr   r   rV   r   NT)r   r   )r   r   )r   r   r   rI   r   r   r2   r3   r   r   reset_ticks	converterunits	set_unitsrv   )rN   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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   ru   r6   patch)rN   r   r   r   r    s    zAxis.reset_ticksr   c             K   s$  t jdddg|d | j|}|rh|dkr@| jj  | jj| |dkr^| jj  | jj| | j  n|dkr| jj| x| jD ]}|j	f | qW |dkr| jj| x| j
D ]}|j	f | qW d|ksd|kr | jj| jjdd p| jjdd 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   )r   rY   rZ   FrU   TN)r   r   )r   r   )r   r   )r   r   )rI   ri   _translate_tick_kwr   clearupdater   r  r   r   r   r   r   getZ	set_colorrv   )rN   r   resetr\   kwtransr   r   r   r   set_tick_params/  s2    




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< x(| D ] }||kr^td||f q^W |j|  |S )NrP   rQ   r   rR   rS   rT   rU   r   rV   rW   rX   rY   rZ   length	directionleftbottomrighttop	labelleftlabelbottom
labelrightlabeltopr[   r   colorsz3keyword %s is not recognized; valid keywords are %s)r   r   
ValueErrorr  )r\   Zkwkeysr  ckeyr   r   r   r	  V  sP    









zAxis._translate_tick_kwc             C   s<   t jj| || x | j| j D ]}|j|| qW d| _d S )NT)r/   r0   ru   r   r   rv   )rN   rw   rx   childr   r   r   ru     s    zAxis.set_clip_pathc             C   s   t ddS )z3Return the view limits ``(min, max)`` of this axis.zDerived must overrideN)r   )rN   r   r   r   r     s    zAxis.get_view_intervalc             C   s   t ddS )a7  
        Set the axis view limits.  This method is for internal use; Matplotlib
        users should typically use e.g. `~.Axes.set_xlim` or `~.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   )rN   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   )rN   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   )rN   r   r   r  r   r   r   set_data_interval  s    zAxis.set_data_intervalc             C   s   | j  \}}||k S )a.  
        Return whether this 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   )rN   lowhighr   r   r   get_inverted  s    zAxis.get_invertedc             C   s   t ddS )a+  
        Set whether this 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   )rN   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   )rN   r   r   r   set_default_intervals  s    zAxis.set_default_intervalsc             C   s   |d krd S |j | j d S )N)r4   r5   )rN   r   r   r   r   rL     s    zAxis._set_artist_propsc             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_bboxeslenmtransformsBboxunionZfrom_extents)rN   r   ticks_to_drawticklabelBoxesticklabelBoxes2bboxbbox2r   r   r   get_ticklabel_extents  s    
zAxis.get_ticklabel_extentsz3.2c             C   s   || _ d| _dS )z"Set the axis to have smart bounds.TN)r   rv   )rN   r   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   )rN   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
| qW ||	}
| j \}}||kr || }}| jr|
rt| 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| qW |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   )r   )r   r   r   r   r   r     s    z&Axis._update_ticks.<locals>.<listcomp>r   r   c                s,   g | ]$}|j    ko kn  r|qS r   )r   )r   r   )ihighilowr   r   r   /  s    r9  )get_majorticklocsr   r   Zformat_ticksr  r+  Zset_locsziprM   r   r   get_minorticklocsr   r  r   r   sortedr!  rG   sortr   rx   r   AssertionErrorr,  Z_interval_contains_closer   )rN   
major_locsZmajor_labelsZmajor_ticksr   rO   r   
minor_locsZminor_labelsZminor_ticksticksZview_lowZ	view_highZdata_lowZ	data_highlocsZ	good_locsZ
interval_tr/  Zloc_tr   )r7  r8  r   r)    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   )r&   r   get_window_extent)r   r   )r   r   r   r   C  s   z)Axis._get_tick_bboxes.<locals>.<listcomp>c                s"   g | ]}|j j r|j j qS r   )r(   r   rD  )r   r   )r   r   r   r   E  s   r   )rN   rB  r   r   )r   r   r*  A  s    

zAxis._get_tick_bboxes)for_layout_onlyc               s"  | j  sdS | j }| j  | j| \}}| j|| | jj| jjj	   fdd| jgD ||}| j
j  r| j
j }|r| jdkr|jdkr|j|j d d |_|jd |_| jd	kr|jdkr|j|j d d |_|jd |_|j| d
d |D }|rtjj|S dS dS )a  
        Return a bounding box that encloses the axis. It only accounts
        tick labels, axis label, and offsetText.

        If *for_layout_only* is True, then the width of the label (if this
        is an x-axis) or the height of the label (if this is a y-axis) is
        collapsed to near zero.  This allows tight/constrained_layout to ignore
        too-long labels when doing their layout.
        Nc             3   s    | ]}|j  r|j V  qd S )N)r   rD  )r   r   )r   r   r   r   a  s   z%Axis.get_tightbbox.<locals>.<genexpr>r   r      g      ?g      ?r   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   )rQ   rG   infheight)r   br   r   r   r   u  s    z&Axis.get_tightbbox.<locals>.<listcomp>)r   r)  _update_label_positionr*  _update_offset_text_positionr   r   r   r   
get_offsetr   rD  	axis_namerQ   x0x1rH  y0y1r   r,  r-  r.  )rN   r   rE  r/  r0  r1  bboxesZbbr   )r   r   get_tightbboxH  s4    





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   )rd   )r+  r   r   rr   r   max)rN   valuesr   r   r   rr   |  s    

zAxis.get_tick_paddingc             O   s   | j  sd S |jt| j d | j }| j||\}}x|D ]}|j| q<W | j| | jj| | j	|| | j
j| jjj  | j
j| |jt d| _d S )N)r   F)r   r   r7   r   r)  r*  r   rJ  r   rK  r   r   r   r   rL  r   rv   )rN   r   r   r   r/  r0  r1  r   r   r   r   r     s    



z	Axis.drawc             C   s   | j  }tjddd |D S )z6Return this Axis' grid lines as a list of `.Line2D`\s.zLine2D gridlinec             S   s   g | ]
}|j qS r   )r$   )r   r   r   r   r   r     s    z&Axis.get_gridlines.<locals>.<listcomp>)r  rI   silent_list)rN   rB  r   r   r   get_gridlines  s    zAxis.get_gridlinesc             C   s   | j S )z)Return the axis label as a Text instance.)r   )rN   r   r   r   	get_label  s    zAxis.get_labelc             C   s   | j S )z.Return the axis offsetText as a Text instance.)r   )rN   r   r   r   get_offset_text  s    zAxis.get_offset_textc             C   s   | j S )z0Return the depth of the axis used by the picker.)r   )rN   r   r   r   get_pickradius  s    zAxis.get_pickradiusc             C   s,   | j  }dd |D }dd |D }|| S )z@Return this Axis' major tick labels, as a list of `~.text.Text`.c             S   s   g | ]}|j j r|j qS r   )r&   r   )r   r   r   r   r   r     s    z,Axis.get_majorticklabels.<locals>.<listcomp>c             S   s   g | ]}|j j r|j qS r   )r(   r   )r   r   r   r   r   r     s    )r  )rN   rB  labels1labels2r   r   r   get_majorticklabels  s    zAxis.get_majorticklabelsc             C   s,   | j  }dd |D }dd |D }|| S )z@Return this Axis' minor tick labels, as a list of `~.text.Text`.c             S   s   g | ]}|j j r|j qS r   )r&   r   )r   r   r   r   r   r     s    z,Axis.get_minorticklabels.<locals>.<listcomp>c             S   s   g | ]}|j j r|j qS r   )r(   r   )r   r   r   r   r   r     s    )r  )rN   rB  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 )a2  
        Get this Axis' tick labels.

        Parameters
        ----------
        minor : bool
           Whether to return the minor or the major ticklabels.

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

           Selects which ticklabels to return

        Returns
        -------
        list of `~matplotlib.text.Text`

        Notes
        -----
        The tick label strings are not populated until a ``draw`` method has
        been called.

        See also: `~.pyplot.draw` and `~.FigureCanvasBase.draw`.
        Nr   r   r   )r   )r^  r]  rI   ri   )rN   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 )z<Return this Axis' major tick lines as a list of `.Line2D`\s.zLine2D ticklines)r  r   r    r"   rI   rV  )rN   linesrB  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 )z<Return this Axis' minor tick lines as a list of `.Line2D`\s.zLine2D ticklines)r  r   r    r"   rI   rV  )rN   r`  rB  r   r   r   r   get_minorticklines  s    
zAxis.get_minorticklinesc             C   s   |r| j  S | j S )z6Return this Axis' tick lines as a list of `.Line2D`\s.)rb  ra  )rN   r   r   r   r   get_ticklines  s    zAxis.get_ticklinesc             C   s
   | j j S )z;Return this Axis' major tick locations in data coordinates.)r   r   )rN   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;Return this Axis' minor tick locations in data coordinates.gh㈵>c                s,   g | ]$\}}t j| d dj  r|qS )r   )ZatolZrtol)rG   iscloser   )r   rO   Ztr_loc)toltr_major_locsr   r   r     s    z*Axis.get_minorticklocs.<locals>.<listcomp>)
r   r   r   r   r   rx   r=  r   remove_overlapping_locsr;  )rN   r@  rA  rx   Ztr_minor_locslohir   )re  rf  r   r<    s    




zAxis.get_minorticklocsz3.3r   c             C   s   |r| j  S | j S )z5Return this Axis' tick locations in data coordinates.)r<  r:  )rN   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 )a;  
        Get the tick directions as a numpy array

        Parameters
        ----------
        minor : bool, default: False
            True to return the minor tick directions,
            False to return the major tick directions.

        Returns
        -------
        numpy array of tick directions
        c             S   s   g | ]
}|j qS r   )rl   )r   r   r   r   r   r   ,  s    z,Axis.get_ticks_direction.<locals>.<listcomp>c             S   s   g | ]
}|j qS r   )rl   )r   r   r   r   r   r   /  s    N)rG   arrayr  r  )rN   r   r   r   r   get_ticks_direction  s
    zAxis.get_ticks_directionc             C   s   t ddS )z!Return the default tick instance.zderived must overrideN)r   )rN   r   r   r   r   r   1  s    zAxis._get_tickc             C   s.   | j }|jdtj| d }tj|dj S )z
        Return the text size of tick labels for this Axis.

        This is a convenience function to avoid having to create a `Tick` in
        `.get_tick_space`, since it is expensive.
        rT   ztick.labelsize)rP   )r   r  r2   r3   rE   ZFontPropertiesZget_size_in_points)rN   rM  r   rP   r   r   r   _get_tick_label_size5  s    zAxis._get_tick_label_sizec             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 )z3Copy the properties from *src* tick to *dest* tick.N)r&   Zupdate_fromr(   r    r"   r$   )rN   srcdestr   r   r   _copy_tick_propsA  s    zAxis._copy_tick_propsc             C   s
   | j j S )zGet the text of the label.)r   get_text)rN   r   r   r   get_label_textK  s    zAxis.get_label_textc             C   s   | j jS )z$Get the locator of the major ticker.)r   r   )rN   r   r   r   get_major_locatorO  s    zAxis.get_major_locatorc             C   s   | j jS )z$Get the locator of the minor ticker.)r   r   )rN   r   r   r   get_minor_locatorS  s    zAxis.get_minor_locatorc             C   s   | j jS )z&Get the formatter of the major ticker.)r   r   )rN   r   r   r   get_major_formatterW  s    zAxis.get_major_formatterc             C   s   | j jS )z&Get the formatter of the minor ticker.)r   r   )rN   r   r   r   get_minor_formatter[  s    zAxis.get_minor_formatterc             C   s`   |dkrt | j }x<t | j|k rP| jdd}| jj| | j| jd | qW | jd| S )z#Return the list of major `.Tick`\s.NT)r   r   )r+  r:  r   r   r   rp  )rN   numticksr   r   r   r   r  _  s    zAxis.get_major_ticksc             C   s`   |dkrt | j }x<t | j|k rP| jdd}| jj| | j| jd | qW | jd| S )z#Return the list of minor `.Tick`\s.NF)r   r   )r+  r<  r   r   r   rp  )rN   rw  r   r   r   r   r  l  s    zAxis.get_minor_ticksc             K   s:  |dk	rDd|kr,t |t |d kr,td|rD| rDtjd d}|j }tjdddg|d	 d
d |j D }d|krd}|jd|d< nd}|dkr|dkr| r| jd  |d< n|dk	r||d< | j	f ddi| |dkr0|dko| r
| j
d  |d< n|dk	r||d< | j	f ddi| d| _dS )aq  
        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)
        Nr   z8'b' and 'visible' specify inconsistent grid visibilitiesz_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>Zgrid_visiblerV   Fr   )r   r   )r   r   )r   r  rI   _warn_externalr8   ri   rA   r   r   r  r   rv   )rN   rI  r   r   ZgridkwZforced_visibilityr   r   r   r   y  s6    



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_axisinforv   )rN   datar  Zneednewrd   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 )zt
        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(  )rN   r   r   r   r   r}    s2    




zAxis._update_axisinfoc             C   s   | j d k	p| jd k	S )N)r  r  )rN   r   r   r   
have_units  s    zAxis.have_unitsc             C   s   t j|r|S | jd kr&t jj|| _| jd kr4|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: )	rz  Z_is_natively_supportedr  r{  r|  convertr  	ExceptionZConversionError)rN   r   reter   r   r   convert_units  s    


zAxis.convert_unitsc             C   s>   || j krdS || _ | j  | jjd | jjd d| _dS )zf
        Set the units for axis.

        Parameters
        ----------
        u : units tag
        Nr  zunits finalizeT)r  r}  r   processrv   )rN   ur   r   r   r    s    
zAxis.set_unitsc             C   s   | j S )zReturn the units for axis.)r  )rN   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   r   r  rv   )rN   r   fontdictr   r   r   r   r    s    zAxis.set_label_textc             C   s   | j || j dS )a  
        Set the formatter of the major ticker.

        In addition to a `~matplotlib.ticker.Formatter` instance,
        this also accepts a ``str`` or function.

        For a ``str`` a `~matplotlib.ticker.StrMethodFormatter` is used.
        The field used for the value must be labeled ``'x'`` and the field used
        for the position must be labeled ``'pos'``.
        See the  `~matplotlib.ticker.StrMethodFormatter` documentation for
        more information.

        For a function, a `~matplotlib.ticker.FuncFormatter` is used.
        The function must take two inputs (a tick value ``x`` and a
        position ``pos``), and return a string containing the corresponding
        tick label.
        See the  `~matplotlib.ticker.FuncFormatter` documentation for
        more information.

        Parameters
        ----------
        formatter : `~matplotlib.ticker.Formatter`, ``str``, or function
        N)_set_formatterr   )rN   r   r   r   r   r  "  s    zAxis.set_major_formatterc             C   s   | j || j dS )aZ  
        Set the formatter of the minor ticker.

        In addition to a `~matplotlib.ticker.Formatter` instance,
        this also accepts a ``str`` or function.
        See `.Axis.set_major_formatter` for more information.

        Parameters
        ----------
        formatter : `~matplotlib.ticker.Formatter`, ``str``, or function
        N)r  r   )rN   r   r   r   r   r  <  s    zAxis.set_minor_formatterc             C   s   t |trtj|}n2t|r8t |tj r8tj|}ntjtj	|d t |tj
r|t|jdkr|t |jtj r|tjd || jkrd| _nd| _||_|j|  d| _d S )N)r   r   z=FixedFormatter should only be used together with FixedLocatorFT)rf   rg   r   ZStrMethodFormattercallableZ
TickHelperFuncFormatterrI   _check_isinstancer   FixedFormatterr+  seqr   FixedLocatorry  r   r   r   r   set_axisrv   )rN   r   levelr   r   r   r  J  s     



zAxis._set_formatterc             C   sH   t jtj|d d| _|| j_| jjr4| jjj| |j	|  d| _
dS )z
        Set the locator of the major ticker.

        Parameters
        ----------
        locator : `~matplotlib.ticker.Locator`
        )r   FTN)rI   r  r   r   r   r   r   r   _set_locatorr  rv   )rN   r   r   r   r   r  d  s    
zAxis.set_major_locatorc             C   sH   t jtj|d d| _|| j_| jjr4| jjj| |j	|  d| _
dS )z
        Set the locator of the minor ticker.

        Parameters
        ----------
        locator : `~matplotlib.ticker.Locator`
        )r   FTN)rI   r  r   r   r   r   r   r   r  r  rv   )rN   r   r   r   r   r  t  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   )rN   r   r   r   r   set_pickradius  s    zAxis.set_pickradiusc             C   s   | j |dS )Nr   )r  )tickdr   posr   r   r   _format_with_dict  s    zAxis._format_with_dict)r   c            K   s  dd |D }|r| j  n| j }t|tjrt|jt|krlt|dkrltdt|j dt| ddd t|j|D }t	j
| j|}tj|}n
tj|}|r| j| | j }| jt|}	n | j| | j }| jt|}	g }
xtt||	D ]\}\}}|j| |||}|jj| |jj| |jj| |jj| |jj rh|
j|j |jj r |
j|j q W d	| _|
S )
aR  
        Set the text values of the tick labels.

        .. warning::
            This method should only be used after fixing the tick positions
            using `.Axis.set_ticks`. Otherwise, the labels may end up in
            unexpected positions.

        Parameters
        ----------
        ticklabels : sequence of str or of `.Text`\s
            Texts for labeling each tick location in the sequence set by
            `.Axis.set_ticks`; the number of labels must match the number of
            locations.
        minor : bool
            If True, set minor ticks instead of major ticks.
        **kwargs
            Text properties.

        Returns
        -------
        list of `.Text`\s
            For each tick, includes ``tick.label1`` if it is visible, then
            ``tick.label2`` if it is visible, in that order.
        c             S   s"   g | ]}t |d r|j n|qS )rq  )hasattrrq  )r   tr   r   r   r     s   z'Axis.set_ticklabels.<locals>.<listcomp>r   z&The number of FixedLocator locations (zN), usually from a call to set_ticks, does not match the number of ticklabels (z).c             S   s   i | ]\}}||qS r   r   )r   rO   Zlabr   r   r   r     s    z'Axis.set_ticklabels.<locals>.<dictcomp>T)rt  rs  rf   r   r  r+  rC  r  r;  	functoolspartialr  r  r  r  r<  r  r  r:  r  	enumeraterM   r&   r   r  r(   r   r   rv   )rN   Z
ticklabelsr   r   r   r  funcr   rC  rB  r  r  rO   r   Z
tick_labelr   r   r   set_ticklabels  sB    




zAxis.set_ticklabelsr  c             K   s(   |dk	r|j | | j|fd|i|S )a  
        Set this Axis' labels with list of string labels.

        .. warning::
            This method should only be used after fixing the tick positions
            using `.Axis.set_ticks`. Otherwise, the labels may end up in
            unexpected positions.

        Parameters
        ----------
        labels : list of str
            The label texts.

        fontdict : dict, optional
            A dictionary controlling the appearance of the ticklabels.
            The default *fontdict* is::

               {'fontsize': rcParams['axes.titlesize'],
                'fontweight': rcParams['axes.titleweight'],
                'verticalalignment': 'baseline',
                'horizontalalignment': loc}

        minor : bool, default: False
            Whether to set the minor ticklabels rather than the major ones.

        Returns
        -------
        list of `~.Text`
            The labels.

        Other Parameters
        ----------------
        **kwargs : `~.text.Text` properties.
        Nr   )r  r  )rN   labelsr  r   r   r   r   r   _set_ticklabels  s    $
zAxis._set_ticklabelsc             C   s   | j |}t|dkrT| j \}}||kr@| jt|t| n| jt|t| d| j_|r~| jt	j
| | jt|S | jt	j
| | jt|S dS )a  
        Set this Axis' tick locations.

        Parameters
        ----------
        ticks : list of floats
            List of tick locations.
        minor : bool, default: False
            If ``False``, set the major ticks; if ``True``, the minor ticks.
        r   TN)r  r+  r   r   minrT  r6   rv   r  r   r  r  r  r  )rN   rB  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   )rN   Zxdirr   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   )rN   r   r   r   r   rJ  +  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   )rN   rR  bboxes2r   r   r   rK  2  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)rN   Znumstepsr   r   r   r  9  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)rN   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 to treat data along this Axis as dates.

        Parameters
        ----------
        tz : str or `datetime.tzinfo`, default: :rc:`timezone`
            The timezone used to create date labels.
        r   Ni  r   )rf   rg   Zdateutil.tztzZgettzr  datetime)rN   r  Zdateutilr   r   r   	axis_dateC  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   )rN   r   r   r   get_tick_spaceT  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)r    r   r"   r&   r(   )r   r   r   r   r   r   i  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)r"   r   r    r(   r&   )r   r   r   r   r   r   o  s   rF  c             s   s8   | ]0}|j j o.|jj o.|jj o.|jj  V  qd S )N)r    r   r"   r&   r(   )r   r   r   r   r   r   u  s   rd   unknownN)r   r   all)rN   r   r   r   r   r   _get_ticks_positionY  s    

zAxis._get_ticks_positionc             C   s   | j S )z;
        Return the label position (top or bottom)
        )label_position)rN   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   )rN   positionr   r   r   set_label_position  s    zAxis.set_label_positionc             C   s
   t  d S )N)r   )rN   r   r   r   r     s    zAxis.get_minpos)r   )N)r   F)N)F)F)FN)F)F)F)N)N)Nr   )N)NF)F)N)dr7   r   r   r   OFFSETTEXTPADr   r1   r   r   r   r   r   r   rg  r   r   r   r   r   rt   r   r  r  staticmethodr	  ru   r   r   r!  r"  r%  r'  r(  rL   r4  rI   r   r5  r6  r)  r*  rS  rr   r/   r   r   rW  rX  rY  rZ  r]  r^  r_  ra  rb  rc  r:  r<  Z_make_keyword_onlyrj  rl  r   rm  rp  rr  rs  rt  ru  rv  r  r  r   r  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rJ  rK  r  r  r  r  r  r  r  r   r   r   r   r   r   t  s   
1


	
'-


I4
&		






5"
K
'
	
%
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)rJ   r6   )rN   )	attr_namelim_namer   r   getter  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  )rK   rJ   r6   r  rT  rv   )rN   r   r   r  ZoldminZoldmax)r  r  r  r   r   r   r     s    
z%_make_getset_interval.<locals>.setterr   Z	_intervalset_)F)r7   )method_namer  r  r   )r  r  r  r   r   _make_getset_interval  s
    r  c                   s   e Zd ZdZ dZ f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  ZS )(XAxisxaxisr   c          	      sz   t  j|| | jjddddtj| jjtj d d| _	| j
jddddtj| jjtj tjd	 tjd
 d d| _d S )Ng      ?r   r  center)r   r   r   r   rx   r  r   r  zxtick.labelsizezxtick.color)r   r   r   r   rx   r   r   )r   r1   r   r   r,  blended_transform_factoryr6   r   IdentityTransformr  r   r2   r3   offset_text_position)rN   r   r   )ra   r   r   r1     s    zXAxis.__init__c             C   s   | j |\}}|dk	r||fS |j|j }}y"| jjj }|j||f\}}W n tk
rf   di fS X | jjjddg\\}	}
\}}d|  kodkn  o|
| j |  k o|
k n  p||  k o|| j k n  }|i fS )z4Test whether the mouse event occurred in the x axis.NFr   r   )r   r   )r   r   )	r|   r   r   r6   r   r&  rx   r  r   )rN   r}   r~   r   r   r   r   xaxesyaxeslrI  rr  inaxisr   r   r   r     s    
zXAxis.containsc             C   s*   |r| j }n| j}t| jdfd|i|S )Nr   r   )r   r   r   r6   )rN   r   r   r   r   r   r     s    zXAxis._get_tickc             C   s,   | j jtjddd|d || _d| _dS )z
        Set the label position (top or bottom)

        Parameters
        ----------
        position : {'top', 'bottom'}
        baseliner  )r  r  )r  TN)r   set_verticalalignmentrI   _check_getitemr  rv   )rN   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.
        )	r5   Z_align_xlabel_grpr  get_siblingsr6   r  r)  r*  extend)
rN   r   rR  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ry&| 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)r   r  ry   r  )r   r  r   get_positionr  r6   spinesr   transform_pathrD   get_extentsKeyErrorr2  r,  r-  r.  rP  r   r   r5   rz   rQ  )rN   r   rR  r  r   r   spine	spinebboxr2  r  r  r   r   r   rJ    s2    
zXAxis._update_label_positionc             C   s   | j j \}}t| dsd| _| jdkrft|s<| jjj}ntj	j
|}|j}|| j| jj d  }n<t|sz| jjj}ntj	j
|}|j}|| j| jj d  }| j j||f dS )zw
        Update the offset_text position based on the sequence of bounding
        boxes of all the ticklabels
        _tick_positionr  ry   N)r   r  r  r  r+  r6   r2  yminr,  r-  r.  rP  r  r5   rz   ymaxrQ  r   )rN   rR  r  r   r   r  r2  r  r   r   r   rK  .  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 )zz
        Return how much space should be reserved for text above and below the
        axes, as a pair of floats.
        r   g        r  )r4  r   r{   rH  r  r   rD  )rN   r   r2  r3  	padPixelsZaboveZbelowr   r   r   get_text_heightsF  s    zXAxis.get_text_heightsc             C   s   t jdddddg|d |dkrH| jdddddd	 d| _| jjd n|dkrx| jdddddd	 d| _| jjd np|dkr| jdddd
 nV|dkr| jdddd
 n<|dkr| jdddddd	 d| _| jjd ndstdd| _dS )a  
        Set the ticks position.

        Parameters
        ----------
        position : {'top', 'bottom', 'both', 'default', '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.
        r  r  r   rd   r   )r  TF)r   r  r  r  r  )r   r  r  z0unhandled parameter not caught by _check_in_listN)rI   ri   r  r  r   r  r?  rv   )rN   r  r   r   r   set_ticks_position\  s2    







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.
        TrY   rZ   r  r   )r   r  N)r   r  r  )rN   r   r   r   r   tick_top  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.
        TrY   rZ   r  r   )r   r  N)r   r  r  )rN   r   r   r   r   tick_bottom  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  rd   r  )r   rF  rd   r  )r  )rN   r   r   r   get_ticks_position  s    zXAxis.get_ticks_positionviewr   r   r~  dataLimc             C   s
   | j jjS )N)r6   r  Zminposx)rN   r   r   r   r     s    zXAxis.get_minposc             C   s0   | j  \}}| jjt||ft|dd d d S )N)reverse)re   )r   r6   Zset_xlimr=  r   )rN   r&  r   rI  r   r   r   r'    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  )r6   r  Zmutatedxr   r  r  r  default_limitsr  r   rv   )rN   ZxminZxmaxdataMutatedviewMutatedr   valminvalmaxr   r   r   r(    s    


zXAxis.set_default_intervalsc             C   sp   | j jjddgddgg}|d d |d d  | j jj d }| jdd }|dkrhttj|| S d	S d S )
Nr   r   ry   r   r   rF     l        i)	r6   r   rx   r5   rz   rm  intrG   floor)rN   endsr  rP   r   r   r   r    s    &zXAxis.get_tick_space)r7   r   r   rM  r1   r   r   r  r  rJ  rK  r  r  r  r  r  r  r   r   r!  r"  r   r'  r(  r  r   r   r   )ra   r   r    s,   +(r  c                   s   e Zd ZdZ dZ f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  ZS )*YAxisyaxisr   c          
      s~   t  j|| | jjddddddtjtj | jjd d| _	| j
jddd	dtj| jjtj tjd
 tjd d d| _d S )Nr   g      ?r  r  Zverticalanchor)r   r   r   r   r   Zrotation_moderx   r  r  zytick.labelsizezytick.color)r   r   r   r   rx   r   r   )r   r1   r   r   r,  r  r  r6   r   r  r   r2   r3   r  )rN   r   r   )ra   r   r   r1     s     zYAxis.__init__c             C   s   | j |\}}|d k	r||fS |j|j }}y"| jjj }|j||f\}}W n tk
rf   di fS X | jjjddg\\}	}
\}}d|  kodkn  o|	| j |  k o|	k n  p||  k o|| j k n  }|i fS )NFr   r   )r   r   )r   r   )	r|   r   r   r6   r   r&  rx   r  r   )rN   r}   r~   r   r   r   r   r  r  r  rI  r  r  r  r   r   r   r     s    
zYAxis.containsc             C   s*   |r| j }n| j}t| jdfd|i|S )Nr   r   )r   r   r   r6   )rN   r   r   r   r   r   r     s    zYAxis._get_tickc             C   sD   | j jd | j jd | j jtjddd|d || _d| _dS )	z
        Set the label position (left or right)

        Parameters
        ----------
        position : {'left', 'right'}
        r  r  r  r  )r  r  )r  TN)r   Zset_rotation_modeZset_horizontalalignmentr  rI   r  r  rv   )rN   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.
        )r5   Z_align_ylabel_grpr  r6   r  r)  r*  r  )	rN   r   rR  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ry&| 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)r   r  ry   r  )r   r  r   r  r  r6   r  r   r  rD   r  r  r2  r,  r-  r.  rN  r   r   r5   rz   rO  )rN   r   rR  r  r   r   r  r  r2  r  r  r   r   r   rJ  '	  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
        ry   N)	r   r  r6   r2  r  r   r  r5   rz   )rN   rR  r  r   r   r  r   r   r   rK  Q	  s    
z"YAxis._update_offset_text_positionc             C   sH   | j j \}}tjddd|d}| j j| | j j||f d| _dS )zT
        Parameters
        ----------
        position : {'left', 'right'}
        r   r   )r  r  )r  TN)r   r  rI   r  Zset_har   rv   )rN   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  )r4  r   r{   rQ   r  r   rD  )rN   r   r2  r3  r  r  r  r   r   r   get_text_widthsi	  s    zYAxis.get_text_widthsc             C   s   t jdddddg|d |dkr@| jdddddd	 | j| n|dkrh| jdddddd	 | j| n^|dkr| 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dstdd| _dS )a  
        Set the ticks position.

        Parameters
        ----------
        position : {'left', 'right', 'both', 'default', '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.
        r  r  r   rd   r   )r  TF)r   r  r  r  r  )r   r  r  z0unhandled parameter not caught by _check_in_listN)rI   ri   r  r  r?  rv   )rN   r  r   r   r   r  {	  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.
        TrY   rZ   r  r   )r   r  N)r   r  r  )rN   r   r   r   r   
tick_right	  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.
        TrY   rZ   r  r   )r   r  N)r   r  r  )rN   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  rd   r  )r   rF  rd   r  )r  )rN   r   r   r   r  	  s    zYAxis.get_ticks_positionr  r   r   r~  r  c             C   s
   | j jjS )N)r6   r  Zminposy)rN   r   r   r   r   	  s    zYAxis.get_minposc             C   s0   | j  \}}| jjt||ft|dd d d S )N)r  )re   )r   r6   Zset_ylimr=  r   )rN   r&  r   rI  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  )r6   r  Zmutatedyr   r  r  r  r  r  r   rv   )rN   r  r  r  r  r   r  r  r   r   r   r(  	  s    


zYAxis.set_default_intervalsc             C   sp   | j jjddgddgg}|d d |d d  | j jj d }| jdd }|dkrhttj|| S dS d S )	Nr   r   ry   r   rF  r  l        i)	r6   r   rx   r5   rz   rm  r  rG   r  )rN   r  r  rP   r   r   r   r  	  s    &zYAxis.get_tick_space)r7   r   r   rM  r1   r   r   r  r  rJ  rK  r  r  r  r  r  r  r  r   r   r!  r"  r   r'  r(  r  r   r   r   )ra   r   r    s.   *$r  )6r   r  r  loggingnumpyrG   Z
matplotlibr2   Zmatplotlib.artistr`   r/   Zmatplotlib.cbookrI   Zmatplotlib.linesr`  r?   Zmatplotlib.scaleZscaler   Zmatplotlib.texttextrE   Zmatplotlib.tickerZtickerr   Zmatplotlib.transformsZ
transformsr,  Zmatplotlib.unitsr  rz  	getLoggerr7   _logrC   ZArtistInspectorr@   Z_line_inspectorZget_settersZ_line_param_namesZaliasdrU  Z_line_param_aliasesr   r0   r   r   r   r   r   r   r  r  r  r   r   r   r   <module>   sV   








  yIG+           (  "