a
    Sic~                    @   s|  d Z ddlZddlZddlZddlmZ ddlZddlZ	ddlm
Z
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 Z/dd e,e/ D Z0G d	d
 d
ej1Z2G dd de2Z3G dd de2Z4G dd dZ5G dd dZ6G dd dej1Z7dd Z8G dd de7Z9G dd de7Z:dS )z)
Classes for the ticks and x and y axis.
    N)Number)_apicbook   c                 C   s   g | ]}t |d  qS r   )list).0d r
   K/var/www/html/django/DPS/env/lib/python3.9/site-packages/matplotlib/axis.py
<listcomp>       r   c                 C   s   g | ]}d | qS Zgrid_r
   )r   namer
   r
   r   r       s   c                       sj  e Zd ZdZdddddddddddddddddddd fdd
Zeejd	d
dddd Zdd Z	dd Z
ejddddd Zdd Zdd Zdd ZdI fdd	Zed d!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zejd5d6 Zd7d8 ZeZd9d: Z fd;d<Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGdH Z&  Z'S )JTicka  
    Abstract base class for the axis ticks, grid lines and labels.

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

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

    NTFr   )sizewidthcolortickdirpad	labelsize
labelcolorzordergridOntick1Ontick2Onlabel1Onlabel2Onmajorlabelrotation
grid_colorgrid_linestylegrid_linewidth
grid_alphac                   s  t    |du rR|r0tjd dv r0tjd }n"|sNtjd dv rNtjd }nd}| |j || _|| _|| _| j	}|r~dnd}|du rtj| d	| d
 }|| _
|du rtj| d	| d }|| _|du rtj| d }|du rtj| d	| d }|| _|	du r"tj| d }	|	dkr<tj| d }	|du rVtj| d }| | |
du r|r~tjjd }
ntjj}
|
| _|du rtjd }|du rtjd }|du rtjd }|du rt|stjd }dd | D }tjg g |d|
||||d	| _tjg g |d|
||||d	| _tjg g f|||||dd|| _t| j _tjtjtj||	|| jd d| _ tjtjtj||	|| jd d| _!| "| | j| j| j| j | j!fD ]}| #| q| $| 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
        Naxes.grid.whichbothr   	axes.gridr&   minorFr   r)   .z.sizez.widthz.colorz.padz.labelcolorinheritz
.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>   r   z!Tick.__init__.<locals>.<dictcomp>none)r   	linestyler   visiblemarkeredgecolor
markersizemarkeredgewidth )r   alphar4   r3   	linewidthmarker   )fontsizer   r4   rotation)%super__init__mplrcParams
set_figurefigureaxes_loc_major__name___size_width	_base_pad_set_labelrotationmlinesLine2Dr   Z_zordermcolors_has_alpha_channelitems	tick1line	tick2linegridlineGRIDLINE_INTERPOLATION_STEPSget_path_interpolation_stepsmtextTextnpnan_labelrotationlabel1label2_apply_tickdir_set_artist_propsupdate_position)selfrE   locr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   kwargsr   Zmajor_minorgrid_kwartist	__class__r
   r   r@   :   s    















zTick.__init__z3.1zTick.label1z3.8)alternativeremovalc                 C   s   | j S N)r]   rb   r
   r
   r   label   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   r   check_in_listr\   )rb   r   modeangler
   r
   r   rL      s    

zTick._set_labelrotationc                 C   sF   |du rt j| j d }tjg d|d || _| j|   | _dS )z;Set tick direction.  Valid values are 'out', 'in', 'inout'.Nz
.direction)inoutinout)r   )	rA   rB   rH   r   rs   _tickdirrK   get_tick_padding_padrb   r   r
   r
   r   r_      s
    zTick._apply_tickdir3.5z`.Axis.set_tick_params`)ri   c                 C   s   |  | d| _d S NT)r_   staler|   r
   r
   r   apply_tickdir   s    
zTick.apply_tickdirc                 C   s   | j S rk   ry   rl   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.              ?      ?)rv   rx   rw   )rI   ry   )rb   paddingr
   r
   r   rz      s
    zTick.get_tick_paddingc                 C   s   | j | j| j| j| jg}|S rk   )rR   rS   rT   r]   r^   )rb   childrenr
   r
   r   get_children   s    zTick.get_childrenc                    s&   t  || | j|| d| _d S r~   )r?   set_clip_pathrT   r   )rb   clippath	transformrg   r
   r   r      s    zTick.set_clip_path3.6c                 C   s   | j j| j d S )NH   )rD   dpirK   rl   r
   r
   r   get_pad_pixels   s    zTick.get_pad_pixelsc                 C   s&   |  |\}}|du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)rb   
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
        )r   TN)_apply_paramsr   rb   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.)rK   rl   r
   r
   r   get_pad  s    zTick.get_padc                 C   s   dS )z Get the default Text 1 instance.Nr
   rl   r
   r
   r   
_get_text1  s    zTick._get_text1c                 C   s   dS )z Get the default Text 2 instance.Nr
   rl   r
   r
   r   
_get_text2  s    zTick._get_text2c                 C   s   dS )z*Get the default line2D instance for tick1.Nr
   rl   r
   r
   r   _get_tick1line  s    zTick._get_tick1linec                 C   s   dS )z*Get the default line2D instance for tick2.Nr
   rl   r
   r
   r   _get_tick2line   s    zTick._get_tick2linec                 C   s   dS )z3Get the default grid Line2d instance for this tick.Nr
   rl   r
   r
   r   _get_gridline#  s    zTick._get_gridlinec                 C   s   | j S )z3Return the tick location (data coords) as a scalar.)rF   rl   r
   r
   r   get_loc&  s    zTick.get_locc                 C   sd   |   sd| _d S |j| j|  d | j| j| j| j| j	fD ]}|
| q>|| j d| _d S )NFgid)get_visibler   
open_grouprH   get_gidrT   rR   rS   r]   r^   drawclose_group)rb   rendererrf   r
   r
   r   r   *  s    z	Tick.drawc                 C   s   | j | d| _dS )z]
        Set the label1 text.

        Parameters
        ----------
        s : str
        TN)r]   set_textr   rb   sr
   r
   r   
set_label16  s    zTick.set_label1c                 C   s   | j | d| _dS )z]
        Set the label2 text.

        Parameters
        ----------
        s : str
        TN)r^   r   r   r   r
   r
   r   
set_label2C  s    zTick.set_label2c                    s.   t  | | j| | j| d| _dS )zl
        Set the url of label1 and label2.

        Parameters
        ----------
        url : str
        TN)r?   set_urlr]   r^   r   )rb   urlrg   r
   r   r   N  s    zTick.set_urlc                 C   s   | | j d S rk   rC   rD   rb   ar
   r
   r   r`   [  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.
        Derived must overrideNNotImplementedErrorrl   r
   r
   r   get_view_interval^  s    zTick.get_view_intervalc                    s  d| j fd| jfd| jfd| jfd| jffD ] \}}| v r,| | q,t fdddD r d	| j| _ d
| j	| _	 d| j
| _
|  d| j | j| jfD ]}|| j || j	 q|  d }| j| |  d }| j| dd   D }d v r, d |d< | jjf i | | jjf i | | D ]\}}t| d| | qXd v r|  d | jj| jd d | jj| jd d dd   D }	| jjf i |	 | jjf i |	 dd   D }
| j jf i |
 d S )Nr   r   r   r   r   c                 3   s   | ]}| v V  qd S rk   r
   r   r/   rd   r
   r   	<genexpr>l  r   z%Tick._apply_params.<locals>.<genexpr>)r   r   r   r   r   r   r   r   r   c                 S   s   i | ]\}}|d v r||qS ))r   r   r
   r.   r
   r
   r   r1   }  r   z&Tick._apply_params.<locals>.<dictcomp>r   r5   _r   r<   )r>   c                 S   s&   i | ]\}}|d v r|dd |qS ))r   r   r-   Nr
   r.   r
   r
   r   r1     s   c                 S   s&   i | ]\}}|t v r|d d |qS r,   )_gridline_param_namesr.   r
   r
   r   r1     s   )rT   rR   rS   r]   r^   set_visiblepopanyrI   rJ   rK   r_   ry   set_markersizeset_markeredgewidth_get_text1_transformset_transform_get_text2_transformrQ   setsetattrrL   r\   )rb   rd   r   targetlinetranstick_kwr/   r0   label_kwre   r
   r   r   r   d  sH    

zTick._apply_paramsc                 C   s   t ddS ):Set the location of tick in data coords with scalar *loc*.r   Nr   rb   rc   r
   r
   r   ra     s    zTick.update_positionc                 C   s   t dd S Nr   r   rl   r
   r
   r   r     s    zTick._get_text1_transformc                 C   s   t dd S r   r   rl   r
   r
   r   r     s    zTick._get_text2_transform)N)(rH   
__module____qualname____doc__r@   propertyr   
deprecatedrm   rL   r_   r   r   rz   r   r   r   r   r   r   r   r   r   r   r   r   martistallow_rasterizationr   r   	set_labelr   r   r`   r   r   ra   r   r   __classcell__r
   r
   rg   r   r   $   sp    
	

/r   c                       sP   e Zd ZdZdZ  fddZdd Zdd Z f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|i | | j}| jjdgdgf|dd | jjdgdgf|dd | jjddgddgf|dd |  \}}}| j	jdd|||d | 
 \}}}| jjdd|||d d S Nr   tick1)datar   r<   tick2gridxyverticalalignmenthorizontalalignmentr   )r?   r@   rE   rR   r   get_xaxis_transformrS   rT   r   r]   r   r^   rb   argsrd   axr   vaharg   r
   r   r@     s*    zXTick.__init__c                 C   s   | j | jS rk   )rE   get_xaxis_text1_transformr{   rl   r
   r
   r   r     s    zXTick._get_text1_transformc                 C   s   | j | jS rk   )rE   get_xaxis_text2_transformr{   rl   r
   r
   r   r     s    zXTick._get_text2_transformc                    sN   t  | tjtjftjtjfdd| j \}}| j| | j| d S )N)|r   rw   rv   rx   )	r?   r_   rM   TICKDOWNTICKUPry   rR   
set_markerrS   rb   r   Zmark1Zmark2rg   r
   r   r_     s    

zXTick._apply_tickdirc                 C   sR   | j |f | j|f | j|f | j| | j| || _d| _dS r   TN)	rR   	set_xdatarS   rT   r]   set_xr^   rF   r   r   r
   r
   r   ra     s    zXTick.update_positionc                 C   s
   | j jjS rk   )rE   viewLim	intervalxrl   r
   r
   r   r     s    zXTick.get_view_intervalrH   r   r   r   r@   r   r   r_   ra   r   r   r
   r
   rg   r   r     s   
r   c                       sP   e Zd ZdZdZ  fddZdd Zdd Z f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|i | | j}| jjdgdgf|dd | jjdgdgf|dd | jjddgddgf|dd |  \}}}| j	jdd|||d | 
 \}}}| jjdd|||d d S r   )r?   r@   rE   rR   r   get_yaxis_transformrS   rT   r   r]   r   r^   r   rg   r
   r   r@     s*    zYTick.__init__c                 C   s   | j | jS rk   )rE   get_yaxis_text1_transformr{   rl   r
   r
   r   r     s    zYTick._get_text1_transformc                 C   s   | j | jS rk   )rE   get_yaxis_text2_transformr{   rl   r
   r
   r   r     s    zYTick._get_text2_transformc                    sN   t  | tjtjftjtjfdd| j \}}| j| | j| d S )N)r   r   r   )	r?   r_   rM   TICKLEFT	TICKRIGHTry   rR   r   rS   r   rg   r
   r   r_     s    

zYTick._apply_tickdirc                 C   sR   | j |f | j|f | j|f | j| | j| || _d| _dS r   )	rR   	set_ydatarS   rT   r]   set_yr^   rF   r   r   r
   r
   r   ra   	  s    zYTick.update_positionc                 C   s
   | j jjS rk   )rE   r   	intervalyrl   r
   r
   r   r     s    zYTick.get_view_intervalr   r
   r
   rg   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| _d| _d S r~   )_locator
_formatter_locator_is_default_formatter_is_defaultrl   r
   r
   r   r@   $  s    zTicker.__init__c                 C   s   | j S rk   )r   rl   r
   r
   r   locator*  s    zTicker.locatorc                 C   s   t |tjstd|| _d S )Nz7locator must be a subclass of matplotlib.ticker.Locator)rp   mtickerLocator	TypeErrorr   rb   r  r
   r
   r   r  .  s    c                 C   s   | j S rk   )r   rl   r
   r
   r   	formatter5  s    zTicker.formatterc                 C   s   t |tjstd|| _d S )Nz;formatter must be a subclass of matplotlib.ticker.Formatter)rp   r  	Formatterr  r   rb   r  r
   r
   r   r  9  s    N)	rH   r   r   r   r@   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 rk   )rG   )rb   r   r
   r
   r   r@   I  s    z_LazyTickList.__init__c                 C   s^   |d u r| S | j r6g |_|jdd}|j| |jS g |_|jdd}|j| |jS d S )NTr   F)rG   
majorTicks	_get_tickappend
minorTicks)rb   instanceclstickr
   r
   r   __get__L  s    z_LazyTickList.__get__N)rH   r   r   r   r@   r  r
   r
   r
   r   r  A  s   r  c                       s  e Zd ZdZdZdZdd ZejddddЇ fd
d	Z	e
dd Zejdd Ze
dd Zejdd Ze
dd Zejdd Ze
dd Zejd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/d0 Zd1d2 Zd3d4 Zd5d6 Z d7d8 Z!d9d: Z"dd<d=Z#e$d>d? Z%dӇ fd@dA	Z&dBdC Z'ddDdEZ(dFdG Z)ddHdIZ*dJdK Z+dLdM Z,dNdO Z-ddPdQdRZ.dSdT Z/e0ddUdV Z1dWdX Z2ddYdZZ3ddd[d\d]Z4d^d_ Z5e6j7d`da Z8dbdc Z9ddde Z:dfdg Z;dhdi Z<djdk Z=dldm Z>ddndoZ?dpdq Z@drds ZAddtduZBdvdw ZCdxdy ZDddzd{d|ZEdd}d~ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdddZOdddZPeQddddddZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdddZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_e
e<e_dd Z`e$dd ZaddzddZbdddddZcddzddZddddzddZedd Zfdd ZgddÄ ZhdddńZiddǄ ZjddɄ Zkdd˄ Zldd̈́ Zmddτ Zn  ZoS )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.
       Nc                 C   s"   dj t| jg| jjdR  S )Nz	{}({},{})r   r   )formattyperH   rE   	transAxesr   rl   r
   r
   r   __str__  s
    zAxis.__str__r   
pickradiusr      c                    s   t    d| _| |j d| _|| _t | _t | _	t
jddgd| _d| _tjtjtjtjd tjd tjd d| _| | j ttjtj| _| | j tjd	 | _|| _t | _t | _|   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`.
        Tunitsunits finalizesignalszaxes.labelsizezaxes.labelweightzaxes.labelcolor)r=   
fontweightr   zaxes.labelpadN)r?   r@   _remove_overlapping_locsrC   rD   isDefault_labelrE   r   r   r)   r   CallbackRegistry	callbacks_autolabelposrX   rY   rZ   r[   rA   rB   rm   r`   
offsetTextlabelpadr  dict_major_tick_kw_minor_tick_kwclear_autoscale_on)rb   rE   r  rg   r
   r   r@     s4    
zAxis.__init__c                 C   s   | j jS rk   r   r  rl   r
   r
   r   isDefault_majloc  s    zAxis.isDefault_majlocc                 C   s   || j _d S rk   r1  rb   valuer
   r
   r   r2    s    c                 C   s   | j jS rk   r   r  rl   r
   r
   r   isDefault_majfmt  s    zAxis.isDefault_majfmtc                 C   s   || j _d S rk   r5  r3  r
   r
   r   r6    s    c                 C   s   | j jS rk   r)   r  rl   r
   r
   r   isDefault_minloc  s    zAxis.isDefault_minlocc                 C   s   || j _d S rk   r7  r3  r
   r
   r   r8    s    c                 C   s   | j jS rk   r)   r  rl   r
   r
   r   isDefault_minfmt  s    zAxis.isDefault_minfmtc                 C   s   || j _d S rk   r9  r3  r
   r
   r   r:    s    Tr  Fc                 C   s   | j S rk   )r%  rl   r
   r
   r   get_remove_overlapping_locs  s    z Axis.get_remove_overlapping_locsc                 C   s   t || _d S rk   )boolr%  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.)docc                 C   s<   d| _ |du 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 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)  rE   r  rm   r   set_positionr   )rb   r   r   r   r
   r
   r   set_label_coords  s    zAxis.set_label_coordsc                 C   s
   | j  S rk   )_scaleget_transformrl   r
   r
   r   rB    s    zAxis.get_transformc                 C   s   | j jS )z#Return this Axis' scale (as a str).)rA  r   rl   r
   r
   r   	get_scale  s    zAxis.get_scalec                 K   sR   t |tjs$tj|| fi || _n|| _| j|  d| _d| _d| _d| _	d S r~   )
rp   mscale	ScaleBasescale_factoryrA  #set_default_locators_and_formattersr2  r8  r6  r:  )rb   r4  rd   r
   r
   r   
_set_scale  s    zAxis._set_scalec                    s   fddj j D \  tj tj}j j  }|j D ]*}|j  j	|fi | |
  d|_qJ tj tj}||krj jf i  fddj jD  dS )a7  
        Set this Axis' scale.

        Parameters
        ----------
        value : {"linear", "log", "symlog", "logit", ...} or `.ScaleBase`
            The axis scale type to apply.

        **kwargs
            Different keyword arguments are accepted, depending on the scale.
            See the respective class keyword arguments:

            - `matplotlib.scale.LinearScale`
            - `matplotlib.scale.LogScale`
            - `matplotlib.scale.SymmetricalLogScale`
            - `matplotlib.scale.LogitScale`
            - `matplotlib.scale.FuncScale`

        Notes
        -----
        By default, Matplotlib supports the above mentioned scales.
        Additionally, custom scales may be registered using
        `matplotlib.scale.register_scale`. These scales can then also
        be used here.
        c                    s   g | ]\}}| u r|qS r
   r
   r   r   axisrl   r
   r   r   *  s   z(Axis._set_axes_scale.<locals>.<listcomp>Tc                    s   i | ]}d | | kqS )scaler
   r   r  r
   r   r1   9  r   z(Axis._set_axes_scale.<locals>.<dictcomp>N)rE   	_axis_maprQ   get_major_locatornonsingularrZ   inf_shared_axesget_siblingsrH  _update_transScaler   autoscale_view_axis_names)rb   r4  rd   Zold_default_limsgr   Znew_default_limsr
   )r   rb   r   _set_axes_scale  s     


zAxis._set_axes_scalec                 C   s   | j |||  S rk   )rA  limit_range_for_scale
get_minpos)rb   vminvmaxr
   r
   r   rW  ;  s    zAxis.limit_range_for_scalec                 C   s   | j S )z'Return whether this Axis is autoscaled.r0  rl   r
   r
   r   _get_autoscale_on>  s    zAxis._get_autoscale_onc                 C   s
   || _ dS )z
        Set whether this Axis is autoscaled when drawing or by
        `.Axes.autoscale_view`.

        Parameters
        ----------
        b : bool
        Nr[  )rb   br
   r
   r   _set_autoscale_onB  s    	zAxis._set_autoscale_onc                 C   s   | j | jg|  |  S rk   )rm   r*  get_major_ticksget_minor_ticksrl   r
   r
   r   r   M  s
    
zAxis.get_childrenc                 C   s,   | j   tjd o tjd dv | j d< d S )Nr'   r$   r%   r   )r-  r/  rA   rB   rl   r
   r
   r   _reset_major_tick_kwQ  s    

zAxis._reset_major_tick_kwc                 C   s,   | j   tjd o tjd dv | j d< d S )Nr'   r$   r(   r   )r.  r/  rA   rB   rl   r
   r
   r   _reset_minor_tick_kwW  s    

zAxis._reset_minor_tick_kwc                 C   s   | j d | d tjddgd| _tjd o>tjd dv | jd	< tjd o\tjd d
v | j	d	< | 
  d| _d| _| d d| _dS )z
        Clear the axis.

        This resets axis properties to their default values:

        - the label
        - the scale
        - locators, formatters and ticks
        - major and minor grid
        - units
        - registered callbacks
        r8   linearr   r!  r"  r'   r$   r%   r   r(   NT)rm   r   rH  r   r'  r(  rA   rB   r-  r.  reset_ticks	converterr   	set_unitsr   rl   r
   r
   r   r/  ]  s     



z
Axis.clearc                 C   sb   z| ` W n ty   Y n0 z| `W n ty6   Y n0 z| | jj W n ty\   Y n0 dS )zs
        Re-initialize the major and minor Tick lists.

        Each list starts with a single fresh Tick.
        N)r  AttributeErrorr  r   rE   patchrl   r
   r
   r   rd    s    zAxis.reset_ticksr   c                 K   s  t jg d|d | |}|rb|dv r<|   | j| |dv rX|   | j| |   n|dv r| j| | j	D ]}|j
f i | q||dv r| j| | jD ]}|j
f i | qd|v sd|v r| j| jddp| jdd d|v 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&   whichr   r&   r)   r&   r   r   Fr   TN)r   rs   _translate_tick_paramsra  r-  updaterb  r.  rd  r  r   r  r*  r   get	set_colorr   )rb   rk  resetrd   kwtransr  r
   r
   r   set_tick_params  s4    




zAxis.set_tick_paramsc                    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 }dddd
d
ddddddd} fdd| D }d v r d}||d< ||d<  D ]}||vrtd||f q|  |S )a  
        Translate the kwargs supported by `.Axis.set_tick_params` to kwargs
        supported by `.Tick._apply_params`.

        In particular, this maps axis specific names like 'top', 'left'
        to the generic tick1, tick2 logic of the axis. Additionally, there
        are some other name translations.

        Returns a new dict of translated kwargs.

        Note: The input *kwargs* are currently modified, but that's ok for
        the only caller.
        r   r   r   r   r   r   r   r   r   r   r   r   r   length	directionleftbottomrighttop	labelleftlabelbottom
labelrightlabeltopr   )ru  rv  r>   rw  rx  ry  rz  r{  r|  r}  r~  c                    s$   i | ]\}}| v r|  |qS r
   )r   )r   Zoldkeynewkeykwr
   r   r1     s   z/Axis._translate_tick_params.<locals>.<dictcomp>colorsz3keyword %s is not recognized; valid keywords are %s)r   rQ   r   
ValueErrorro  )r  Zallowed_keyskeymaprs  ckeyr
   r  r   rn    sJ    



zAxis._translate_tick_paramsc                    s6   t  || | j| j D ]}||| qd| _d S r~   )r?   r   r  r  r   )rb   r   r   childrg   r
   r   r     s    zAxis.set_clip_pathc                 C   s   t ddS )z3Return the ``(min, max)`` view limits of this axis.r   Nr   rl   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.
        r   Nr   rb   rY  rZ  ignorer
   r
   r   set_view_interval  s    zAxis.set_view_intervalc                 C   s   t ddS )z3Return the ``(min, max)`` data limits of this axis.r   Nr   rl   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.
        r   Nr   r  r
   r
   r   set_data_interval  s    zAxis.set_data_intervalc                 C   s   |   \}}||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   )rb   lowhighr
   r
   r   get_inverted  s    zAxis.get_invertedc                 C   s0   |   \}}| jt||ft|dddi 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.
        reversero   N)r   _set_limsortedr<  )rb   invertedr   r]  r
   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
   rl   r
   r
   r   set_default_intervals4  s    zAxis.set_default_intervals)emitc                   s&   fdd j j D \} j j|||ffgdd  j | j} j | j}|du sf|du r  \}}|du r~|}|du r|}  dkr|dks|dkr  \}}|dkrt	d| d	 |}|dkrt	d| d	 |}||kr
t	d
| d t
||k}  ||\}} ||\}}t||gt
|d\}} j||dd  j j|  j D ]}	d|	j|< qv|dur t
| |r j j| d j   j j|  j D ]D}
|
 j ur|
j| j||d|d |
j jkr|
jj  qd _||fS )a`  
        Set view limits.

        This method is a helper for the Axes ``set_xlim``, ``set_ylim``, and
        ``set_zlim`` methods.

        Parameters
        ----------
        v0, v1 : float
            The view limits.  (Passing *v0* as a (low, high) pair is not
            supported; normalization must occur in the Axes setters.)
        emit : bool, default: True
            Whether to notify observers of limit change.
        auto : bool or None, default: False
            Whether to turn on autoscaling of the x-axis. True turns on, False
            turns off, None leaves unchanged.
        c                    s   g | ]\}}| u r|qS r
   r
   rI  rl   r
   r   r   T  s   z!Axis._set_lim.<locals>.<listcomp>F)convertNlogr   zAttempt to set non-positive z)lim on a log-scaled axis will be ignored.z)Attempting to set identical low and high z<lims makes transformation singular; automatically expanding.r  Tr  Zlim_changed)r  ro   )rE   rL  rQ   _process_unit_info_validate_converted_limitsconvert_unitsr   rC  r   warn_externalr<  rM  rN  rW  r  r  rP  rQ  _stale_viewlimsr^  r(  processr  rD   canvas	draw_idler   )rb   v0v1r  ro   r   Zold0old1r  r   otherr
   rl   r   r  B  sT    



zAxis._set_limc                 C   s   |d u rd S | | j d S rk   r   r   r
   r
   r   r`     s    zAxis._set_artist_propsc                 C   sp   |   }| ||\}}t|r.tj|}ntjdddd}t|rVtj|}ntjdddd}||fS )z>Get the extents of the tick labels on either side of the axes.r   )_update_ticks_get_ticklabel_bboxeslenmtransformsBboxunionfrom_extents)rb   r   ticks_to_drawtlb1tlb2bbox1bbox2r
   r
   r   get_ticklabel_extents  s    zAxis.get_ticklabel_extentsc              	   C   sd  |   }| jj|}| t|}| jj| t|||D ](\}}}|| |	| |
| q>|  }| jj|}| t|}	| jj| t|	||D ](\}}}|| |	| |
| qg ||	}
|  \}}||kr|| }}|  ||g}g }|
D ]J}z|  | }W n tyB   Y n0 t||r|| q|S )z
        Update ticks (position and labels) using the current data interval of
        the axes.  Return the list of ticks that will be drawn.
        )get_majorticklocsr   r  format_ticksr_  r  set_locszipra   r   r   get_minorticklocsr)   r`  r   rB  r   r   AssertionErrorr  _interval_contains_closer  )rb   
major_locsZmajor_labelsZmajor_ticksr  rc   rm   
minor_locsZminor_labelsZminor_ticksticksZview_lowZ	view_highZ
interval_tr  Zloc_tr
   r
   r   r    s<    




zAxis._update_ticksc                    s6    du r| j    fdd|D  fdd|D fS )z8Return lists of bboxes for ticks' label1's and label2's.Nc                    s"   g | ]}|j  r|j  qS r
   )r]   r   get_window_extentr   r  r   r
   r   r     s   z.Axis._get_ticklabel_bboxes.<locals>.<listcomp>c                    s"   g | ]}|j  r|j  qS r
   )r^   r   r  r  r  r
   r   r     s   )rD   _get_renderer)rb   r  r   r
   r  r   r    s    


zAxis._get_ticklabel_bboxes)for_layout_onlyc                   sB  |   sdS  du r| j  |  }|   | | \}}| || | j| j	j
  g  fdd| jfD ||}| j  r| 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 |_|| d
d |D }|r:t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    | ]}|  r| V  qd S rk   )r   r  )r   r   r  r
   r   r     s   z%Axis.get_tightbbox.<locals>.<genexpr>r   r      r   r   r   c                 S   sH   g | ]@}d |j   k r tjk rn qd |j  k r<tjk rn q|qS r   )r   rZ   rO  height)r   r]  r
   r
   r   r     s   8z&Axis.get_tightbbox.<locals>.<listcomp>)r   rD   r  r  _update_label_positionr  _update_offset_text_positionr*  r   r   r  
get_offsetrm   r  	axis_namer   x0x1r  y0y1r  r  r  r  )rb   r   r  r  r  r  bboxesbbr
   r  r   get_tightbbox  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  rz   r  max)rb   valuesr
   r
   r   rz     s    

zAxis.get_tick_paddingc                 O   s   |   sd S |jt|  d |  }| ||\}}|D ]}|| q:| | | j| | 	|| | j
| jj  | j
| |t d| _d S )Nr   F)r   r   rH   r   r  r  r   r  rm   r  r*  r   r   r  r  r   r   )rb   r   r   rd   r  r  r  r  r
   r
   r   r     s    

z	Axis.drawc                 C   s   |   }t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
   )rT   r  r
   r
   r   r   1  r   z&Axis.get_gridlines.<locals>.<listcomp>)r_  r   silent_list)rb   r  r
   r
   r   get_gridlines-  s    zAxis.get_gridlinesc                 C   s   | j S )z)Return the axis label as a Text instance.)rm   rl   r
   r
   r   	get_label3  s    zAxis.get_labelc                 C   s   | j S )z.Return the axis offsetText as a Text instance.)r*  rl   r
   r
   r   get_offset_text7  s    zAxis.get_offset_textc                 C   s   | j S )z0Return the depth of the axis used by the picker.)_pickradiusrl   r
   r
   r   get_pickradius;  s    zAxis.get_pickradiusc                 C   s4   |    |  }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  r|j qS r
   r]   r   r  r
   r
   r   r   C  r   z,Axis.get_majorticklabels.<locals>.<listcomp>c                 S   s   g | ]}|j  r|j qS r
   r^   r   r  r
   r
   r   r   D  r   )r  r_  rb   r  Zlabels1Zlabels2r
   r
   r   get_majorticklabels?  s
    zAxis.get_majorticklabelsc                 C   s4   |    |  }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  r|j qS r
   r  r  r
   r
   r   r   K  r   z,Axis.get_minorticklabels.<locals>.<listcomp>c                 S   s   g | ]}|j  r|j qS r
   r  r  r
   r
   r   r   L  r   )r  r`  r  r
   r
   r   get_minorticklabelsG  s
    zAxis.get_minorticklabelsc                 C   sf   |durR|dkr|   S |dkr(|  S |dkr@|  |    S tjg d|d |r^|   S |  S )aq  
        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`
        Nr)   r   r&   ri  rj  )r  r  r   rs   )rb   r)   rk  r
   r
   r   get_ticklabelsO  s    zAxis.get_ticklabelsc                 C   s:   g }|   }|D ]}||j ||j qtd|S )z<Return this Axis' major tick lines as a list of `.Line2D`\s.Line2D ticklines)r_  r  rR   rS   r   r  rb   linesr  r  r
   r
   r   get_majorticklinesn  s    zAxis.get_majorticklinesc                 C   s:   g }|   }|D ]}||j ||j qtd|S )z<Return this Axis' minor tick lines as a list of `.Line2D`\s.r  )r`  r  rR   rS   r   r  r  r
   r
   r   get_minorticklinesw  s    zAxis.get_minorticklinesc                 C   s   |r|   S |  S )z6Return this Axis' tick lines as a list of `.Line2D`\s.)r  r  rb   r)   r
   r
   r   get_ticklines  s    zAxis.get_ticklinesc                 C   s
   | j  S )z;Return this Axis' major tick locations in data coordinates.r   r  rl   r
   r
   r   r    s    zAxis.get_majorticklocsc           
      C   s   t | j }| jr| j }| j }||}||}t	|| 
 \}}|| d }t j|dddf |dddf |ddjdd}	||	  }|S )z;Return this Axis' minor tick locations in data coordinates.gh㈵>Nr   )atolrtolr<   rJ  )rZ   asarrayr)   r  remove_overlapping_locsr   rA  rB  r   r  r   iscloser   )
rb   r  r  r   Ztr_minor_locsZtr_major_locslohitolmaskr
   r
   r   r    s    



 
zAxis.get_minorticklocsr)   c                C   s   |r|   S |  S )a  
        Return this Axis' tick locations in data coordinates.

        The locations are not clipped to the current axis limits and hence
        may contain locations that are not visible in the output.

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

        Returns
        -------
        numpy array of tick locations
        )r  r  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 )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
   r   r  r
   r
   r   r     r   z,Axis.get_ticks_direction.<locals>.<listcomp>c                 S   s   g | ]
}|j qS r
   r   r  r
   r
   r   r     r   N)rZ   arrayr`  r_  r  r
   r
   r   get_ticks_direction  s    zAxis.get_ticks_directionc                 C   sH   | j du rtd| jj d|r(| jn| j}| j | jdfd|i|S )z!Return the default tick instance.NzThe Axis subclass z3 must define _tick_class or reimplement _get_tick()r   r   )_tick_classr   rh   rH   r-  r.  rE   )rb   r   r   r
   r
   r   r    s    
zAxis._get_tickc                 C   s.   | j }|dtj| d }tj|d 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.
        r   ztick.labelsize)r   )r-  rp  rA   rB   rX   FontPropertiesget_size_in_points)rb   r  r   r   r
   r
   r   _get_tick_label_size  s
    zAxis._get_tick_label_sizec                 C   s^   |du s|du rdS |j |j  |j|j |j|j |j|j |j|j dS )z3Copy the properties from *src* tick to *dest* tick.N)r]   update_fromr^   rR   rS   rT   )rb   srcdestr
   r
   r   _copy_tick_props  s    zAxis._copy_tick_propsc                 C   s
   | j  S )zGet the text of the label.)rm   get_textrl   r
   r
   r   get_label_text  s    zAxis.get_label_textc                 C   s   | j jS )z$Get the locator of the major ticker.r  rl   r
   r
   r   rM    s    zAxis.get_major_locatorc                 C   s   | j jS )z$Get the locator of the minor ticker.)r)   r  rl   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  rl   r
   r
   r   get_major_formatter  s    zAxis.get_major_formatterc                 C   s   | j jS )z&Get the formatter of the minor ticker.)r)   r  rl   r
   r
   r   get_minor_formatter  s    zAxis.get_minor_formatterc                 C   s\   |du rt |  }t | j|k rN| jdd}| j| | | jd | q| jd| S )z#Return the list of major `.Tick`\s.NTr  r   )r  r  r  r  r  r  rb   numticksr  r
   r
   r   r_    s    zAxis.get_major_ticksc                 C   s\   |du rt |  }t | j|k rN| jdd}| j| | | jd | q| jd| S )z#Return the list of minor `.Tick`\s.NFr  r   )r  r  r  r  r  r  r  r
   r
   r   r`    s    zAxis.get_minor_ticksr}   r]  r4   c                 K   s   |r$|du rd}n|s$t d d}| }t jg d|d dd | D }|dv r|du rl| jd	  n||d	< | jf d
di| |dv r|du r| jd	  n||d	< | jf d
di| d| _dS )a  
        Configure the grid lines.

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

            If *visible* 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)
        NTz_First parameter to grid() is false, but line properties are supplied. The grid will be enabled.ri  rj  c                 S   s   i | ]\}}d | |qS r   r
   )r   r   r4  r
   r
   r   r1   1  r   zAxis.grid.<locals>.<dictcomp>rm  r   rk  r)   rl  r   )	r   r  lowerrs   rQ   r.  rt  r-  r   )rb   r4   rk  rd   Zgridkwr
   r
   r   r     s,    
z	Axis.gridc                 C   sj   t j|}|du rdS | j|k}|| _| j|| }|durT| jdu rT| | n|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_converterre  default_unitsr   rf  _update_axisinfor   )rb   r   re  Zneednewrn   r
   r
   r   update_units<  s    
zAxis.update_unitsc                 C   s  | j du rdS | j | j| }|du r*dS |jdurZ| jj|jkrZ| jrZ| |j d| _|jdur| j	j|jkr| j
r| |j d| _
|jdur| jj|jkr| jr| |j d| _|jdur| j	j|jkr| jr| |j d| _|jdur| jr| |j d| _|   dS )zt
        Check the axis converter for the stored units to see if the
        axis info needs to be updated.
        NT)re  axisinfor   majlocr   r  r2  set_major_locatorminlocr)   r8  set_minor_locatormajfmtr  r6  set_major_formatterminfmtr:  set_minor_formatterrm   r&  set_label_textr  )rb   r   r
   r
   r   r  Q  sJ    




zAxis._update_axisinfoc                 C   s   | j d up| jd uS rk   )re  r   rl   r
   r
   r   
have_unitss  s    zAxis.have_unitsc              
   C   s   t |r|S | jd u r&t j|| _| jd u r4|S z| j|| j| }W n6 ty } zt d||W Y d }~n
d }~0 0 |S )Nz*Failed to convert value(s) to axis units: )	r  _is_natively_supportedre  r  r  r  r   	ExceptionConversionError)rb   r   reter
   r
   r   r  v  s    


zAxis.convert_unitsc                    s   || j krdS | jj D ]6\ }| |u r fdd| jj  | jD } qXq| g}|D ]0}||_ |  |jd |jd d|_	q\dS )z
        Set the units for axis.

        Parameters
        ----------
        u : units tag

        Notes
        -----
        The units of any shared axis will also be updated.
        Nc                    s   g | ]}t |  d qS r  getattrr   r   r  r
   r   r     s   z"Axis.set_units.<locals>.<listcomp>r   r!  T)
r   rE   rL  rQ   rP  rQ  r  r(  r  r   )rb   urJ  sharedr
   r  r   rf    s    

zAxis.set_unitsc                 C   s   | j S )zReturn the units for axis.)r   rl   r
   r
   r   	get_units  s    zAxis.get_unitsc                 K   s>   d| _ | j| |dur&| 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&  rm   r   ro  r   )rb   rm   fontdictrd   r
   r
   r   r    s    zAxis.set_label_textc                 C   s   |  || 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   r
  r
   r
   r   r    s    zAxis.set_major_formatterc                 C   s   |  || 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)   r
  r
   r
   r   r    s    zAxis.set_minor_formatterc                 C   s   t |trt|}n0t|r6t |tjs6t|}ntjtj	|d t |tj
rxt|jdkrxt |jtjsxtd || jkrd| _nd| _||_||  d| _d S )N)r  r   z=FixedFormatter should only be used together with FixedLocatorFT)rp   rq   r  StrMethodFormattercallable
TickHelperFuncFormatterr   check_isinstancer	  FixedFormatterr  seqr  FixedLocatorr  r   r6  r:  r  set_axisr   )rb   r  levelr
   r
   r   r!    s&    




zAxis._set_formatterc                 C   sH   t jtj|d d| _|| j_| jjr4| jj| |	|  d| _
dS )z
        Set the locator of the major ticker.

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

        Parameters
        ----------
        locator : `~matplotlib.ticker.Locator`
        r,  FTN)r   r&  r  r  r8  r)   r  r  r-  r*  r   r  r
   r
   r   r    s    
zAxis.set_minor_locatorc                 C   s$   t |tr|dk rtd|| _dS )z
        Set the depth of the axis used by the picker.

        Parameters
        ----------
        pickradius : float
            The acceptance radius for containment tests.
            See also `.Axis.contains`.
        r   z pick radius should be a distanceN)rp   r   r  r  )rb   r  r
   r
   r   set_pickradius   s    
zAxis.set_pickradiuszGThe acceptance radius for containment tests. See also `.Axis.contains`.c                 C   s   |  |dS )Nr8   )rp  )tickdr   posr
   r
   r   _format_with_dict3  s    zAxis._format_with_dictc                K   s  zdd |D }W n$ t y6   t |dddY n0 |rD|  n|  }t|tjrt|jt|krt|dkrtdt|j dt| d	d
d t	|j|D }t
| j|}t|}n
t|}|r| | |  }| t|}	n | | |  }| t|}	g }
tt	||	D ]\}\}}|| |||}|j| |j| |j| |j| |j r|
|j |j r(|
|j q(d| _|
S )a  
        [*Discouraged*] Set the text values of the tick labels.

        .. admonition:: Discouraged

            The use of this method is discouraged, because of the dependency
            on tick positions. In most cases, you'll want to use
            ``set_[x/y]ticks(positions, labels)`` instead.

            If you are using this method, you should always fix the tick
            positions before, e.g. by using `.Axis.set_ticks` or by explicitly
            setting a `~.ticker.FixedLocator`. Otherwise, ticks are free to
            move and 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| n|qS )r  )hasattrr  )r   tr
   r
   r   r   X  s   z'Axis.set_ticklabels.<locals>.<listcomp>=z must be a sequenceNr   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   rc   labr
   r
   r   r1   g  r   z'Axis.set_ticklabels.<locals>.<dictcomp>T)r  r  rM  rp   r  r)  r  locsr  r  	functoolspartialr1  r%  r'  r  r  r`  r  r  r_  	enumeratera   r]   r   _internal_updater^   r   r  r   )rb   
ticklabelsr)   rd   r  r/  funcr  r6  r  r  r0  rc   r  
tick_labelr
   r
   r   set_ticklabels7  sV     





zAxis.set_ticklabels)r   r)   c                K   s(   |dur| | | 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)   )ro  r>  )rb   labelsr   r)   rd   r
   r
   r   _set_ticklabels  s    #
zAxis._set_ticklabelsc                   s   |  |}| jj D ]6\ }| |u r fdd| jj  | jD } qTq| g}t|rz|D ]}|t|t	| q`d| j_
|r| t| | t|S | t| | t|S d S )Nc                    s   g | ]}t |  d qS r  r  r  r  r
   r   r     s   z,Axis._set_tick_locations.<locals>.<listcomp>T)r  rE   rL  rQ   rP  rQ  r  r  minr  r   r  r  r)  r`  r  r_  )rb   r  r)   rJ  r  r
   r  r   _set_tick_locations  s"    

zAxis._set_tick_locationsc                K   s0   | j ||d}|dur,| j|fd|i| |S )ah  
        Set this Axis' tick locations and optionally labels.

        If necessary, the view limits of the Axis are expanded so that all
        given ticks are visible.

        Parameters
        ----------
        ticks : list of floats
            List of tick locations.  The axis `.Locator` is replaced by a
            `~.ticker.FixedLocator`.

            Some tick formatters will not label arbitrary tick positions;
            e.g. log formatters only label decade ticks by default. In
            such a case you can set a formatter explicitly on the axis
            using `.Axis.set_major_formatter` or provide formatted
            *labels* yourself.
        labels : list of str, optional
            List of tick labels. If not set, the labels are generated with
            the axis tick `.Formatter`.
        minor : bool, default: False
            If ``False``, set the major ticks; if ``True``, the minor ticks.
        **kwargs
            `.Text` properties for the labels. These take effect only if you
            pass *labels*. In other cases, please use `~.Axes.tick_params`.

        Notes
        -----
        The mandatory expansion of the view limits is an intentional design
        choice to prevent the surprise of a non-visible tick. If you need
        other limits, you should set the limits explicitly after setting the
        ticks.
        r  Nr)   )rB  r>  )rb   r  r?  r)   rd   resultr
   r
   r   	set_ticks  s    "zAxis.set_ticksc                    s    fdd j j D }t|dkr.g g fS |\} jj| }g }g }| j D ]@}t|| d}| }	|	|	|\}
}|
|
 |
| qT||fS )z
        Get the bounding boxes for this `.axis` and its siblings
        as set by `.Figure.align_xlabels` or  `.Figure.align_ylabels`.

        By default it just gets bboxes for self.
        c                    s(   g | ] \}}| j jv r| u r|qS r
   )rD   _align_label_groupsrI  rl   r
   r   r     s   z1Axis._get_tick_boxes_siblings.<locals>.<listcomp>r<   rJ  )rE   rL  rQ   r  rD   rE  rQ  r  r  r  extend)rb   r   
axis_namesr  grouperr  bboxes2r   rJ  r  Ztlbr  r
   rl   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.
        r   Nr   )rb   r   r
   r
   r   r    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.
        r   Nr   )rb   r  rI  r
   r
   r   r    s    z!Axis._update_offset_text_positionc                 C   s@   t |trddl}|j|}| tddddddd| dS )z
        Set 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<   )rp   rq   dateutil.tztzgettzr	  datetime)rb   rL  dateutilr
   r
   r   	axis_date  s    
zAxis.axis_datec                 C   s
   t  dS )z>Return the estimated number of ticks that can fit on the axis.Nr   rl   r
   r
   r   get_tick_space,  s    zAxis.get_tick_spacec                 C   sj   | j d }| jd }tdd ||fD r.dS tdd ||fD rHdS tdd ||f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  o0|j  o0|j o0|j  V  qd S rk   rR   r   rS   r]   r^   r  r
   r
   r   r   A  s   

z+Axis._get_ticks_position.<locals>.<genexpr>r<   c                 s   s:   | ]2}|j  o0|j  o0|j o0|j  V  qd S rk   )rS   r   rR   r^   r]   r  r
   r
   r   r   G  s   

r  c                 s   s8   | ]0}|j  o.|j o.|j o.|j  V  qd S rk   rR  r  r
   r
   r   r   M  s   
rn   unknownN)r  r  all)rb   r   r)   r
   r
   r   _get_ticks_position1  s    

zAxis._get_ticks_positionc                 C   s   | j S )z;
        Return the label position (top or bottom)
        )label_positionrl   r
   r
   r   get_label_positionV  s    zAxis.get_label_positionc                 C   s
   t  dS )
        Set the label position (top or bottom)

        Parameters
        ----------
        position : {'top', 'bottom'}
        Nr   rb   positionr
   r
   r   set_label_position\  s    zAxis.set_label_positionc                 C   s
   t  d S rk   r   rl   r
   r
   r   rX  f  s    zAxis.get_minpos)r  )N)r   F)N)F)F)N)N)FN)F)F)N)N)Nr   )N)N)N)prH   r   r   r   OFFSETTEXTPADr  r  r   make_keyword_onlyr@   r   r2  r  r6  r8  r:  r  r  r  r;  r=  r  r@  rB  rC  rH  rV  rW  r\  r^  r   ra  rb  r/  rd  rt  staticmethodrn  r   r   r  r  r  r  r  r  r  r`   r   r  r  r  r  rz   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rM  r  r  r   r_  r`  rename_parameterr   r	  r  r  r  rf  r  r  r  r  r!  r  r  r.  r  r1  r>  r@  rB  rD  rJ  r  r  rP  rQ  rU  rW  r[  rX  r   r
   r
   rg   r   r  a  s   .










+$
'
5

K
+
	3

		

	


*"

T''
%
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 rk   )r  rE   rl   )	attr_namelim_namer
   r   getterp  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 )NTr  )r   r  rE   rA  r  r   )rb   rY  rZ  r  oldminZoldmaxr`  rb  ra  r  r
   r   r  t  s    z%_make_getset_interval.<locals>.setterget_	_intervalset_)F)rH   )method_namera  r`  r
   rd  r   _make_getset_intervalj  s
    ri  c                       s   e Zd ZdZ dZeZ fddZdd Zdd Zd	d
 Z	dd Z
ed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  ZS )#XAxisxaxisr   c              
      s~   t  j|i | | jjddddt| jjt d d| _	| j
jddddt| jjt tjd	 tjd
 d d| _d S )Nr   r   rz  centerr   rx  r<   ry  zxtick.labelsizezxtick.colorr   r   r   r   r   r=   r   )r?   r@   rm   r   r  blended_transform_factoryrE   r  IdentityTransformrV  r*  rA   rB   offset_text_positionrb   r   rd   rg   r
   r   r@     s&    zXAxis.__init__c                 C   s   |  |\}}|dur||fS |j|j }}z"| jj }|||f\}}W n tyh   di f Y S 0 | 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   rE   r  r  r   r  r  rb   r   r   r   r   r   r   ZxaxesZyaxeslr]  rr3  Zinaxisr
   r
   r   r     s    zXAxis.containsc                 C   s,   | j tjddd|d || _d| _dS )rX  baselinerz  )rz  rx  rZ  TN)rm   set_verticalalignmentr   check_getitemrV  r   rY  r
   r
   r   r[    s    
zXAxis.set_label_positionc                 C   s  | j s
dS | j|d\}}| j \}}| jdkrz| jjd }| }W n tyd   | jj	}Y n0 t
j||g }|j}	| j||	| j| jj d  f nnz| jjd }| }W n ty   | jj	}Y n0 t
j||g }|j}
| j||
| j| jj d  f dS )y
        Update the label position based on the bounding box enclosing
        all the ticklabels and axis spine
        Nr  rx  r   rz  )r)  rJ  rm   get_positionrV  rE   spinesr  KeyErrorbboxr  r  r  r  r?  r+  rD   r   r  )rb   r   r  rI  r   r   spine	spinebboxr  rx  rz  r
   r
   r   r    s2    
zXAxis._update_label_positionc                 C   s   | j  \}}t| dsd| _| jdkrft|s<| jjj}ntj	
|}|j}|| j| jj d  }n<t|sz| jjj}ntj	
|}|j}|| j| jj d  }| j ||f dS )w
        Update the offset_text position based on the sequence of bounding
        boxes of all the ticklabels
        _tick_positionrx  r   N)r*  r|  r2  r  r  rE   r  yminr  r  r  r  r\  rD   r   ymaxr  r?  )rb   r  rI  r   r   rx  r  rz  r
   r
   r   r    s    

z"XAxis._update_offset_text_positionr   c                 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 )zz
        Return how much space should be reserved for text above and below the
        Axes, as a pair of floats.
        r   r   rz  )r  r  r   r  rW  rm   r  )rb   r   r  r  
pad_pixelsabovebelowr
   r
   r   get_text_heights	  s    zXAxis.get_text_heightsc                 C   s   t jg d|d |dkrB| jdddddd d| _| jd n|dkrr| jdddddd d| _| 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d ndsJ 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.
        )rz  rx  r&   rn   r2   rx  rz  r&   TF)rk  rz  r~  rx  r|  rx  )rk  rz  rx  r2   rn   0unhandled parameter not caught by _check_in_listN)r   rs   rt  r  r*  ry  r   rY  r
   r
   r   set_ticks_position	  s>    



zXAxis.set_ticks_positionc                 C   s>   d}d| j v 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   r   rz  r&   )rk  r~  Nr-  r  rt  rb   rm   r
   r
   r   tick_topA	  s    


zXAxis.tick_topc                 C   s>   d}d| j v 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   r   rx  r&   )rk  r|  Nr  r  r
   r
   r   tick_bottomM	  s    


zXAxis.tick_bottomc                 C   s   ddddd|    S )zW
        Return the ticks position ("top", "bottom", "default", or "unknown").
        rx  rz  rn   rS  r<   r  rn   rS  rU  rl   r
   r
   r   get_ticks_positionY	  s
    zXAxis.get_ticks_positionviewr   r   r   dataLimc                 C   s
   | j jjS rk   )rE   r  minposxrl   r
   r
   r   rX  f	  s    zXAxis.get_minposc                 C   sd   | j j sZ| j j sZ| jd urZ| j| j| }|jd urZ| |j\}}||f| j j_	d| _
d S r~   )rE   r  mutatedxr   re  r
  r   default_limitsr  r   r   )rb   r   xminxmaxr
   r
   r   r  i	  s    


zXAxis.set_default_intervalsc                 C   sV   t j | jj| jj }|jd }| 	dd }|dkrNt
t|| S dS d S )Nr   r   r  r   )r  r  unittransformedrE   r  rD   dpi_scale_transr   r  intrZ   floorrb   endsru  r   r
   r
   r   rQ  v	  s    

zXAxis.get_tick_space)rH   r   r   r  r   r  r@   r   r[  r  r  r   r   r  r  r  r  r  ri  r   r  r  r  rX  r  rQ  r   r
   r
   rg   r   rj    s.   (
(rj  c                       s   e Zd ZdZ dZeZ fddZdd Zdd Zd	d
 Z	dd Z
dd Zed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  ZS )%YAxisyaxisr   c                    s   t  j|i | | jjddddddtt | jjd d| _	| j
jddd	dt| jjt tjd
 tjd d d| _d S )Nr   r   rx  rl  verticalanchor)r   r   r   r   r>   rotation_moder   rw  rw  zytick.labelsizezytick.colorrm  )r?   r@   rm   r   r  rn  ro  rE   r  rV  r*  rA   rB   rp  rq  rg   r
   r   r@   	  s(    zYAxis.__init__c                 C   s   |  |\}}|d ur||fS |j|j }}z"| jj }|||f\}}W n tyh   di f Y S 0 | 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  rr  r   r<   rs  rt  r
   r
   r   r   	  s    zYAxis.containsc                 C   s8   | j d | j tjddd|d || _d| _dS )z
        Set the label position (left or right)

        Parameters
        ----------
        position : {'left', 'right'}
        r  rx  rz  rw  ry  rx  TN)rm   set_rotation_modery  r   rz  rV  r   rY  r
   r
   r   r[  	  s    
zYAxis.set_label_positionc                 C   s  | j s
dS | j|d\}}| j \}}| jdkrz| jjd }| }W n tyd   | jj	}Y n0 t
j||g }|j}	| j|	| j| jj d  |f nnz| jjd }| }W n ty   | jj	}Y n0 t
j||g }|j}
| j|
| j| jj d  |f dS )r{  Nr  rw  r   ry  )r)  rJ  rm   r|  rV  rE   r}  r  r~  r  r  r  r  r  r?  r+  rD   r   r  )rb   r   r  rI  r   r   r  r  r  rw  ry  r
   r
   r   r  	  s2    
zYAxis._update_label_positionc                 C   s`   | j  \}}d| jjv r,| jjd  }n| jj}|j}| j ||| j| j	j
 d  f dS )r  outliner   N)r*  r|  rE   r}  r  r  r  r?  r\  rD   r   )rb   r  rI  r   r   r  rz  r
   r
   r   r  	  s    z"YAxis._update_offset_text_positionc                 C   sH   | j  \}}tjddd|d}| j | | j ||f d| _dS )zT
        Parameters
        ----------
        position : {'left', 'right'}
        r   r<   r  rx  TN)r*  r|  r   rz  set_har?  r   )rb   rZ  r   r   r
   r
   r   set_offset_position	  s
    zYAxis.set_offset_positionr   c                 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   r   rw  )r  r  r   r   rW  rm   r  )rb   r   r  r  r  rw  ry  r
   r
   r   get_text_widths
  s    zYAxis.get_text_widthsc                 C   s   t jg d|d |dkr:| jdddddd | | n|dkrb| jdddddd | | 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sJ 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.
        )rw  ry  r&   rn   r2   rx  ry  r&   TF)rk  ry  r}  rw  r{  rw  )rk  ry  rw  r2   rn   r  N)r   rs   rt  r  r   rY  r
   r
   r   r  
  s6    



zYAxis.set_ticks_positionc                 C   s>   d}d| j v 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   r   ry  r&   )rk  r}  Nr  r  r
   r
   r   
tick_right;
  s    


zYAxis.tick_rightc                 C   s>   d}d| j v 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   r   rw  r&   )rk  r{  Nr  r  r
   r
   r   	tick_leftH
  s    


zYAxis.tick_leftc                 C   s   ddddd|    S )zW
        Return the ticks position ("left", "right", "default", or "unknown").
        rw  ry  rn   rS  r  r  rl   r
   r
   r   r  U
  s
    zYAxis.get_ticks_positionr  r   r   r   r  c                 C   s
   | j jjS rk   )rE   r  minposyrl   r
   r
   r   rX  b
  s    zYAxis.get_minposc                 C   sd   | j j sZ| j j sZ| jd urZ| j| j| }|jd urZ| |j\}}||f| j j_	d| _
d S r~   )rE   r  mutatedyr   re  r
  r   r  r  r   r   )rb   r   r  r  r
   r
   r   r  e
  s    


zYAxis.set_default_intervalsc                 C   sV   t j | jj| jj }|jd }| 	dd }|dkrNt
t|| S dS d S )Nr   r   r  r   r  )r  r  r  r  rE   r  rD   r  r  r  r  rZ   r  r  r
   r
   r   rQ  r
  s    

zYAxis.get_tick_space)rH   r   r   r  r   r  r@   r   r[  r  r  r  r   r   r  r  r  r  r  ri  r   r  r  r  rX  r  rQ  r   r
   r
   rg   r   r  	  s0   '
$r  );r   rN  r7  loggingnumbersr   numpyrZ   
matplotlibrA   r   r   matplotlib.artistrf   r   matplotlib.colorsr  rO   matplotlib.linesr  rM   matplotlib.scalerK  rD  matplotlib.texttextrX   matplotlib.tickertickerr  matplotlib.transforms
transformsr  matplotlib.unitsr   r  	getLoggerrH   _logrU   ArtistInspectorrN   Z_line_inspectorget_settersZ_line_param_namesaliasdr  Z_line_param_aliasesr   Artistr   r   r   r   r  r  ri  rj  r  r
   r
   r
   r   <module>   s^   
  |==)              |