B
    ]”t\#b ã               @   s”  d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	Z	d dl
Z
d dlZd dlZd dlmZmZ d dlmZmZmZmZ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, d dl-m.Z/ d dl0m1Z2 d dl3m4Z4 d dl5m6Z7 d dl8m9Z: d dl;m<Z< d d	l!m=Z= d d
l>m?Z? d dl@mAZAmBZB e CeD¡ZEdd„ ZFG dd„ deGƒZHG dd„ de#jIƒZJdS )é    )ÚOrderedDictN)ÚReal)Ú
attrgetter)ÚcbookÚrcParams)Ú_OrderedSetÚ	_check_1dÚ_string_to_boolÚiterableÚindex_ofÚ	get_label)Ú	docstring)Ú	OffsetBox)Úallow_rasterization)ÚLegend)ÚcyclerÚvalidate_axisbelowc       	      C   s  d}d}d}yPt  | ¡}ytt| ƒƒ}W n tk
rB   |||fS X | |krV|||fS d}W n tk
rp   Y nX |  d¡dkrd}|  dd¡} |  d¡dkr®d}|  dd¡} |  d¡dkrÌd}|  dd¡} dd	„ | D ƒ}d}xî|t|ƒk rÌ|| }|tj	kr|dk	rtd
|  ƒ‚|}n¤|tj
krF|dk	r@td|  ƒ‚|}n||t  ¡ krp|dk	rjtd|  ƒ‚|}nR|dkr¶|t|ƒd k r¶t||d  ƒ}t  d |¡¡}|d7 }ntd| ƒ‚|d7 }qàW |dkrê|dkrêtd }|dkrød}|dkrd}|||fS )a	  
    Process a MATLAB style color/line style format string.  Return a
    (*linestyle*, *color*) tuple as a result of the processing.  Default
    values are ('-', 'b').  Example format strings include:

    * 'ko': black circles
    * '.b': blue dots
    * 'r--': red dashed lines
    * 'C2--': the third color in the color cycle, dashed lines

    .. seealso::

        :func:`~matplotlib.Line2D.lineStyles` and
        :attr:`~matplotlib.colors.cnames`
            for all possible styles and color format string.
    Nz--r   Ú z-.ú ÚNonec             S   s   g | ]}|‘qS © r   )Ú.0Úcr   r   ú4lib/python3.7/site-packages/matplotlib/axes/_base.pyú
<listcomp>\   s    z(_process_plot_format.<locals>.<listcomp>z1Illegal format string "%s"; two linestyle symbolsz.Illegal format string "%s"; two marker symbolsz-Illegal format string "%s"; two color symbolsÚCé   zC{}z*Unrecognized character %c in format stringzlines.linestyle)ÚmcolorsZto_rgbaÚstrÚintÚ
ValueErrorÚfindÚreplaceÚlenÚmlinesZ
lineStylesZlineMarkersZget_named_colors_mappingÚformatr   )	ZfmtÚ	linestyleÚmarkerÚcolorZfmtintÚcharsÚir   Zcolor_cycle_numberr   r   r   Ú_process_plot_format'   sp    











r+   c               @   sŠ   e Zd ZdZd"dd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!S )#Ú_process_plot_var_argsa3  
    Process variable length arguments to the plot command, so that
    plot commands like the following are supported::

      plot(t, s)
      plot(t1, s1, t2, s2)
      plot(t1, s1, 'ko', t2, s2)
      plot(t1, s1, 'ko', t2, s2, 'r--', t3, e3)

    an arbitrary number of *x*, *y*, *fmt* are allowed
    Úplotc             C   s   || _ || _|  ¡  d S )N)ÚaxesÚcommandÚset_prop_cycle)Úselfr.   r/   r   r   r   Ú__init__   s    z_process_plot_var_args.__init__c             C   s   | j | jdœS )N)r.   r/   )r.   r/   )r1   r   r   r   Ú__getstate__”   s    z#_process_plot_var_args.__getstate__c             C   s   |  ¡ | _|  ¡  d S )N)ÚcopyÚ__dict__r0   )r1   Ústater   r   r   Ú__setstate__˜   s    
z#_process_plot_var_args.__setstate__c             O   sL   |s|r t |ƒdkr*|d d kr*td }n
t||Ž}t |¡| _|j| _d S )Nr   r   zaxes.prop_cycle)r#   r   r   Ú	itertoolsÚcycleÚprop_cyclerÚkeysÚ
_prop_keys)r1   ÚargsÚkwargsr:   r   r   r   r0   œ   s
     

z%_process_plot_var_args.set_prop_cyclec             O   s´   | j jd k	r¤| j jd k	r¤| d| j jj¡}| j jdkrB| d|¡}| d| j jj¡}| j jdkrl| d|¡}|| j jjkrˆ| j j |¡ || j jjkr¤| j j |¡ | j||Ž}|S )NÚxunitsÚpolarÚ
thetaunitsÚyunitsÚrunits)r.   ÚxaxisÚyaxisÚpopÚunitsÚnameÚ	set_unitsÚ_grab_next_args)r1   r=   r>   r?   rB   Úretr   r   r   Ú__call__§   s    z_process_plot_var_args.__call__c             C   s   d| j krdS t| jƒd S )z#Return the next color in the cycle.r(   Úk)r<   Únextr:   )r1   r   r   r   Úget_next_color¼   s    
z%_process_plot_var_args.get_next_colorc             K   s"   | j dkstdƒ‚|jf |Ž d S )Nr-   z$set_lineprops only works with "plot")r/   ÚAssertionErrorÚset)r1   Úliner>   r   r   r   Úset_linepropsÂ   s    z$_process_plot_var_args.set_linepropsc             K   s"   | j dkstdƒ‚|jf |Ž d S )NÚfillz%set_patchprops only works with "fill")r/   rP   rQ   )r1   Z	fill_polyr>   r   r   r   Úset_patchpropsÆ   s    z%_process_plot_var_args.set_patchpropsc             C   sþ   | j jd k	r^| j jd k	r^| j j |¡}| j j |¡}| jdkr^|rN| j  |¡}|r^| j  |¡}t|ƒ}t|ƒ}|jd |jd kr–t	d 
|j|j¡ƒ‚|jdksª|jdkr¾t	d 
|j|j¡ƒ‚|jdkrÚ|d d …tjf }|jdkrö|d d …tjf }||fS )Nr-   r   zAx and y must have same first dimension, but have shapes {} and {}é   z=x and y can be no greater than 2-D, but have shapes {} and {}r   )r.   rD   rE   Úupdate_unitsr/   Úconvert_xunitsÚconvert_yunitsr   Úshaper    r%   ÚndimÚnpZnewaxis)r1   ÚxÚyZbxZbyr   r   r   Ú_xy_from_xyÊ   s*    


z"_process_plot_var_args._xy_from_xyc                sd   | j }|dkrtƒ }|| }t‡ fdd„|D ƒƒr\t| jƒ ¡ }x|D ]}| |d¡ qFW ni }|S )a!  
        Only advance the cycler if the cycler has information that
        is not specified in any of the supplied tuple of dicts.
        Ignore any keys specified in the `ignore` set.

        Returns a copy of defaults dictionary if there are any
        keys that are not found in any of the supplied dictionaries.
        If the supplied dictionaries have non-None values for
        everything the property cycler has, then just return
        an empty dictionary. Ignored keys are excluded from the
        returned dictionary.

        Nc             3   s$   | ]‰ t ‡ fd d„ˆD ƒƒV  qdS )c             3   s   | ]}|  ˆ d ¡d kV  qd S )N)Úget)r   Úkw)rM   r   r   ú	<genexpr>  s    z@_process_plot_var_args._getdefaults.<locals>.<genexpr>.<genexpr>N)Úall)r   )r>   )rM   r   rb     s   z6_process_plot_var_args._getdefaults.<locals>.<genexpr>)r<   rQ   ÚanyrN   r:   r4   rF   )r1   Úignorer>   Z	prop_keysÚdefault_dictÚpr   )r>   r   Ú_getdefaultsò   s    

z#_process_plot_var_args._getdefaultsc                sB   x<|D ]4‰ t ‡ fdd„|D ƒƒrx|D ]}|ˆ  |ˆ < q&W qW dS )zÕ
        Given a defaults dictionary, and any other dictionaries,
        update those other dictionaries with information in defaults if
        none of the other dictionaries contains that information.

        c             3   s   | ]}|  ˆ d ¡d kV  qd S )N)r`   )r   ra   )rM   r   r   rb     s    z6_process_plot_var_args._setdefaults.<locals>.<genexpr>N)rc   )r1   Údefaultsr>   ra   r   )rM   r   Ú_setdefaults  s    

z#_process_plot_var_args._setdefaultsc             C   s4   ||–}|   d |¡}|  ||¡ tj||f|Ž}|S )N)rh   rj   r$   ÚLine2D)r1   r]   r^   ra   r>   rf   Úsegr   r   r   Ú	_makeline  s
    z _process_plot_var_args._makelinec             C   s¼   |  ¡ }|  ¡ }dddddh}x&| ¡ D ]\}}|d k	r(| |¡ q(W |  ||¡}|  ||¡ | dd ¡}	| dd ¡ |  ||¡ tjt	 
||f¡|	| dd¡|d	 d
}
| j|
f|Ž |
S )Nr'   Z
markersizeZmarkeredgecolorZmarkerfacecolorZmarkeredgewidthr(   rT   TÚclosed)Ú	facecolorrT   rn   )r4   ÚitemsÚaddrh   rj   r`   rF   ÚmpatchesZPolygonr\   Zcolumn_stackrU   )r1   r]   r^   ra   r>   ZignoresrM   Úvrf   ro   rl   r   r   r   Ú	_makefill#  s$    

z _process_plot_var_args._makefillc             C   sÖ  g }t |ƒdkr>t|d tƒr>t|d ƒ\}}}|d d… }n t |ƒdkrTtdƒ‚n
d\}}}tdd„ |D ƒƒrxtdƒ‚i }x,td	|||fƒD ]\}}	|	d k	rŽ|	||< qŽW d
|ks¾|d
 d krÐt|d d ƒ|d
< t |ƒdkröt|d ƒ}
t|d ƒ}nt	|d ƒ\}
}|  
|
|¡\}
}| jdkr*| j}n| dd¡|d< | j}|
jd |jd  }}|dkr€|dkr€||kr€t dd¡ xPtt||ƒƒD ]>}||
d d …|| f |d d …|| f ||ƒ}| |¡ qW |S )Nr   éÿÿÿÿé   z!third arg must be a format string)NNNc             s   s   | ]}|d kV  qd S )Nr   )r   rs   r   r   r   rb   `  s    z4_process_plot_var_args._plot_args.<locals>.<genexpr>z(x, y, and format string must not be None)r&   r'   r(   ÚlabelrV   r   r-   rn   Tz2.2zGcycling among columns of inputs with non-matching shapes is deprecated.)r#   Ú
isinstancer   r+   r    rd   Úzipr   r   r   r_   r/   rm   r`   rt   rZ   r   Úwarn_deprecatedÚrangeÚmaxÚappend)r1   Útupr>   rK   r&   r'   r(   ra   rM   rs   r]   r^   ÚfuncZncxZncyÚjrl   r   r   r   Ú
_plot_argsS  s@    

.z!_process_plot_var_args._plot_argsc             o   sf   x`|r`|d d… |dd …  }}|rLt |d tƒrL||d f7 }|dd … }|  ||¡E d H  qW d S )NrV   r   r   )rx   r   r   )r1   r=   r>   Úthisr   r   r   rJ   ƒ  s    z&_process_plot_var_args._grab_next_argsN)r-   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   r3   r7   r0   rL   rO   rS   rU   r_   rh   rj   rm   rt   r   rJ   r   r   r   r   r,   ƒ   s    
(00r,   c                   sì  e Zd ZdZdZe ¡ Ze ¡ Ze ¡ Z	e
dd„ ƒZejdd„ ƒZdd„ ZdVdd„Z‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdWdd„Zdd„ Zdd„ ZdXd d!„Zd"d#„ Zd$d%„ Zd&d'„ ZdYd)d*„ZdZd,d-„Zd[d.d/„Zd0d1„ Zd2d3„ Z d4d5„ Z!d6d7„ Z"d8d9„ Z#d\d<d=„Z$d>d?„ Z%e
e &d@¡dAdB„ ƒƒZ'dCdD„ Z(dEdF„ Z)e)Z*dGdH„ Z+e+Z,dIdJ„ Z-dKdL„ Z.dMdN„ Z/d]dOdP„Z0dQdR„ Z1d^dSdT„Z2dUdV„ Z3d_dWdX„Z4dYdZ„ Z5d[d\„ Z6d`d]d^„Z7d_d`„ Z8dadb„ Z9dcdd„ Z:dedf„ Z;dgdh„ Z<didj„ Z=dkdl„ Z>dmdn„ Z?dodp„ Z@dqdr„ ZAdsdt„ ZBdudv„ ZCdwdx„ ZDdydz„ ZEd{d|„ ZFdad}d~„ZGdd€„ ZHdd‚„ ZIdƒd„„ ZJd…d†„ ZKd‡dˆ„ ZLd‰dŠ„ ZMd‹dŒ„ ZNddŽ„ ZOdd„ ZPdbd‘d’„ZQdcd“d”„ZRddd•d–„ZSd—d˜„ ZTded™dš„ZUd›dœ„ ZVddž„ ZWdŸd „ ZXd¡d¢„ ZYd£d¤„ ZZd¥d¦„ Z[d§d¨„ Z\e
d©dª„ ƒZ]e]jd«dª„ ƒZ]d¬d­„ Z^d®d¯„ Z_ddd	d°œd±d²„Z`d³d´„ Zadµd¶„ Zbdfd·d¸„Zcdgd¹dº„Zdd»d¼„ Zed½d¾„ Zfegdhd¿dÀ„ƒZhdÁdÂ„ ZidÃdÄ„ ZjdÅdÆ„ ZkdÇdÈ„ ZldÉdÊ„ ZmdËdÌ„ ZndÍdÎ„ ZoepjqdidÐdÑ„ƒZrd+d
dddddÒœdÓdÔ„ZsdjdÕdÖ„Ztdkd×dØ„ZudÙdÚ„ ZvdÛdÜ„ ZwdÝdÞ„ Zxdßdà„ Zydádâ„ Zzdldãdä„Z{dådæ„ Z|dçdè„ Z}dmdddéœdêdë„Z~dìdí„ Zdîdï„ Z€dndðdñ„Zdodòdó„Z‚dôdõ„ Zƒdöd÷„ Z„dpdødù„Z…dqdúdû„Z†düdý„ Z‡dþdÿ„ Zˆd d„ Z‰drdd„ZŠdd„ Z‹dsdddœdd„ZŒd	d
„ Zdd„ ZŽdtdd„Zdudd„Zdd„ Z‘dd„ Z’dvdd„Z“dwdd„Z”dxdd„Z•dy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/d0„ Z d1d2„ Z¡d3d4„ Z¢d5d6„ Z£dzd8d9„Z¤d:d;„ Z¥d<d=„ Z¦d>d?„ Z§d@dA„ Z¨dBdC„ Z©dDdE„ ZªdFdG„ Z«dHdI„ Z¬d{dJdK„Z­dLdM„ Z®dNdO„ Z¯dPdQ„ Z°dRdS„ Z±dTdU„ Z²‡  Z³S (|  Ú	_AxesBasez
    Zrectilinearc             C   s   dS )NTr   )r1   r   r   r   Ú_hold•  s    z_AxesBase._holdc             C   s   d S )Nr   )r1   Úvaluer   r   r   rˆ   ™  s    c             C   s   d  t| ƒj| jj¡S )Nz({0}({1[0]:g},{1[1]:g};{1[2]:g}x{1[3]:g}))r%   Útyperƒ   Ú	_positionÚbounds)r1   r   r   r   Ú__str__  s    z_AxesBase.__str__NTr   c
                sä  t j ˆ ¡ t|tjƒr |ˆ _ntjj|Ž ˆ _ˆ jjdk sFˆ jj	dk rNt
dƒ‚ˆ j ¡ ˆ _ˆ ˆ _dˆ _dˆ _dˆ _|ˆ _|ˆ _|dk	r”ˆ j ˆ |¡ |dk	rªˆ j ˆ |¡ ˆ  |¡ ˆ  |¡ ˆ  |
 dd¡¡ ˆ  ¡ ˆ _ˆ  ¡  |dkròtd }|ˆ _|ˆ _ˆ   td	 ¡ dˆ _!i ˆ _"ˆ  #¡  dˆ _$dˆ _%dˆ _&ˆ  'd
¡ ˆ  (d¡ |rVˆ  )|¡ |	rfˆ  *|	¡ ˆ  +|
¡ ˆ j,dk	r–ˆ j,j- .d‡ fdd„¡ˆ _/ˆ j0dk	r¼ˆ j0j- .d‡ fdd„¡ˆ _1ˆ j2td oÐtd td oàtd td oðtd td o td td otd td o td td o0td td o@td dd	 ˆ j2td o\td td oltd td o|td td oŒtd td oœtd td o¬td  td o¼td td oÌtd  d!d	 dˆ _3dˆ _4dS )"a  
        Build an axes in a figure.

        Parameters
        ----------
        fig : `~matplotlib.figure.Figure`
            The axes is build in the `.Figure` *fig*.

        rect : [left, bottom, width, height]
            The axes is build in the rectangle *rect*. *rect* is in
            `.Figure` coordinates.

        sharex, sharey : `~.axes.Axes`, optional
            The x or y `~.matplotlib.axis` is shared with the x or
            y axis in the input `~.axes.Axes`.

        frameon : bool, optional
            True means that the axes frame is visible.

        **kwargs
            Other optional keyword arguments:
            %(Axes)s

        Returns
        -------
        axes : `~.axes.Axes`
            The new `~.axes.Axes` object.
        r   z/Width and height specified must be non-negativeÚautoÚboxr   NZaxes_locatorzaxes.facecolorzaxes.axisbelowTzunits finalizec                  s   ˆ j ddS )NT)Úscalex)Ú_on_units_changedr   )r1   r   r   Ú<lambda>þ  s    z$_AxesBase.__init__.<locals>.<lambda>c                  s   ˆ j ddS )NT)Úscaley)r‘   r   )r1   r   r   r’     s    z	xtick.topzxtick.minor.topzxtick.bottomzxtick.minor.bottomzxtick.labeltopzxtick.labelbottomz
ytick.leftzytick.minor.leftzytick.rightzytick.minor.rightzytick.labelleftzytick.labelrightÚminor)	ÚtopÚbottomÚlabeltopÚlabelbottomÚleftÚrightÚ	labelleftÚ
labelrightÚwhichzxtick.major.topzxtick.major.bottomzytick.major.leftzytick.major.rightÚmajor)5ÚmartistÚArtistr2   rx   ÚmtransformsÚBboxr‹   Úfrom_boundsÚwidthÚheightr    ÚfrozenÚ_originalPositionr.   Ú_aspectÚ_adjustableÚ_anchorÚ_sharexÚ_shareyÚ_shared_x_axesÚjoinÚ_shared_y_axesÚ	set_labelÚ
set_figureÚset_axes_locatorr`   Ú_gen_axes_spinesÚspinesÚ
_init_axisr   Ú
_facecolorÚ_frameonÚset_axisbelowÚ_rasterization_zorderZ
_connectedÚclaÚ	fmt_xdataÚ	fmt_ydataÚ_cachedRendererÚset_navigateÚset_navigate_modeÚ
set_xscaleÚ
set_yscaleÚupdaterD   Ú	callbacksZconnectZ_xcidrE   Z_ycidÚtick_paramsÚ
_layoutboxÚ_poslayoutbox)r1   ÚfigZrectro   ZframeonÚsharexÚshareyrw   ÚxscaleÚyscaler>   r   )r1   r   r2   ¡  s˜    '















z_AxesBase.__init__c                sV   t ƒ  ¡ }xdD ]}d ||< qW x0dD ](}t| |ƒ}| |krF| | ¡nd ||< q&W |S )N)r½   rÅ   rÆ   )r­   r¯   Ú_twinned_axes)Úsuperr3   ÚgetattrÚget_siblings)r1   r6   ÚkeyÚgrouper_nameZgrouper)Ú	__class__r   r   r3   %  s    



z_AxesBase.__getstate__c             C   s<   x*dD ]"}|  |¡}|rt| |ƒj|Ž  qW || _d| _d S )N)r­   r¯   rÌ   T)rF   rÎ   r®   r5   Ú_stale)r1   r6   rÑ   Zsiblingsr   r   r   r7   3  s    

z_AxesBase.__setstate__c             O   sp   | j }d}| jr$| j ¡ r$| j ¡ }d}| jrB| j ¡ rB| j ¡ }t |j| |j	| g|j
| |j| gg¡S )zc
        get the axes bounding box in display space; *args* and
        *kwargs* are empty
        r   )ÚbboxÚaxisonrD   Úget_visibleZget_tick_paddingrE   r¡   r¢   Úx0Úy0Úx1Úy1)r1   r=   r>   rÔ   Zx_padZy_padr   r   r   Úget_window_extent=  s    

z_AxesBase.get_window_extentc             C   sl   t  | ¡| _| jd  | j¡ | jd  | j¡ t  | ¡| _| jd  | j¡ | jd  | j¡ |  ¡  dS )zAmove this out of __init__ because non-separable axes don't use itr–   r•   r™   rš   N)ÚmaxisZXAxisrD   r´   Zregister_axisZYAxisrE   Ú_update_transScale)r1   r   r   r   rµ   L  s    z_AxesBase._init_axisc             C   sT   t j | |¡ t | j|j¡| _tj 	¡ | _
tj ¡ | _t t ¡ ¡| _|  ¡  dS )zt
        Set the `.Figure` for this `.Axes`.

        Parameters
        ----------
        fig : `.Figure`
        N)rŸ   r    r±   r¡   ÚTransformedBboxr‹   ZtransFigurerÔ   r¢   ÚnullÚdataLimZunitÚviewLimÚTransformWrapperÚIdentityTransformÚ
transScaleÚ_set_lim_and_transforms)r1   rÇ   r   r   r   r±   V  s    
z_AxesBase.set_figurec             C   sr   t  | j¡| _t  t  ¡ ¡| _t  t  | j	| j¡¡| _
| j| j
| j  | _t  | j| j¡| _t  | j| j¡| _dS )a  
        set the *_xaxis_transform*, *_yaxis_transform*,
        *transScale*, *transData*, *transLimits* and *transAxes*
        transformations.

        .. note::

            This method is primarily used by rectilinear projections
            of the :class:`~matplotlib.axes.Axes` class, and is meant
            to be overridden by new kinds of projection axes that need
            different transformations and limits. (See
            :class:`~matplotlib.projections.polar.PolarAxes` for an
            example.

        N)r¡   ZBboxTransformTorÔ   Ú	transAxesrâ   rã   rä   ZBboxTransformFromrÞ   rá   ZtransLimitsÚ	transDataÚblended_transform_factoryÚ_xaxis_transformÚ_yaxis_transform)r1   r   r   r   rå   j  s    z!_AxesBase._set_lim_and_transformsÚgridc             C   sF   |dkr| j S |dkr$| jd  ¡ S |dkr:| jd  ¡ S tdƒ‚dS )aÐ  
        Get the transformation used for drawing x-axis labels, ticks
        and gridlines.  The x-direction is in data coordinates and the
        y-direction is in axis coordinates.

        .. note::

            This transformation is primarily used by the
            :class:`~matplotlib.axis.Axis` class, and is meant to be
            overridden by new kinds of projections that may need to
            place axis elements in different locations.

        rë   Útick1r–   Útick2r•   zunknown value for whichN)ré   r´   Úget_spine_transformr    )r1   r   r   r   r   Úget_xaxis_transform‘  s    z_AxesBase.get_xaxis_transformc             C   s6   t jd }| jddt dd| d | jj¡ d|fS )a¾  
        Get the transformation used for drawing x-axis labels, which
        will add the given amount of padding (in points) between the
        axes and the label.  The x-direction is in data coordinates
        and the y-direction is in axis coordinates.  Returns a
        3-tuple of the form::

          (transform, valign, halign)

        where *valign* and *halign* are requested alignments for the
        text.

        .. note::

            This transformation is primarily used by the
            :class:`~matplotlib.axis.Axis` class, and is meant to be
            overridden by new kinds of projections that may need to
            place axis elements in different locations.

        zxtick.alignmentrì   )r   r   ru   éH   r•   )Ú
matplotlibr   rï   r¡   ÚScaledTranslationÚfigureÚdpi_scale_trans)r1   Ú
pad_pointsÚlabels_alignr   r   r   Úget_xaxis_text1_transformª  s
    


z#_AxesBase.get_xaxis_text1_transformc             C   s2   t jd }| jddt d|d | jj¡ d|fS )aË  
        Get the transformation used for drawing the secondary x-axis
        labels, which will add the given amount of padding (in points)
        between the axes and the label.  The x-direction is in data
        coordinates and the y-direction is in axis coordinates.
        Returns a 3-tuple of the form::

          (transform, valign, halign)

        where *valign* and *halign* are requested alignments for the
        text.

        .. note::

            This transformation is primarily used by the
            :class:`~matplotlib.axis.Axis` class, and is meant to be
            overridden by new kinds of projections that may need to
            place axis elements in different locations.

        zxtick.alignmentrí   )r   r   rð   r–   )rñ   r   rï   r¡   rò   ró   rô   )r1   rõ   rö   r   r   r   Úget_xaxis_text2_transformÆ  s
    


z#_AxesBase.get_xaxis_text2_transformc             C   sF   |dkr| j S |dkr$| jd  ¡ S |dkr:| jd  ¡ S tdƒ‚dS )aÐ  
        Get the transformation used for drawing y-axis labels, ticks
        and gridlines.  The x-direction is in axis coordinates and the
        y-direction is in data coordinates.

        .. note::

            This transformation is primarily used by the
            :class:`~matplotlib.axis.Axis` class, and is meant to be
            overridden by new kinds of projections that may need to
            place axis elements in different locations.

        rë   rì   r™   rí   rš   zunknown value for whichN)rê   r´   rî   r    )r1   r   r   r   r   Úget_yaxis_transformá  s    z_AxesBase.get_yaxis_transformc             C   s6   t jd }| jddt d| d d| jj¡ |dfS )a¾  
        Get the transformation used for drawing y-axis labels, which
        will add the given amount of padding (in points) between the
        axes and the label.  The x-direction is in axis coordinates
        and the y-direction is in data coordinates.  Returns a 3-tuple
        of the form::

          (transform, valign, halign)

        where *valign* and *halign* are requested alignments for the
        text.

        .. note::

            This transformation is primarily used by the
            :class:`~matplotlib.axis.Axis` class, and is meant to be
            overridden by new kinds of projections that may need to
            place axis elements in different locations.

        zytick.alignmentrì   )r   ru   rð   r   rš   )rñ   r   rù   r¡   rò   ró   rô   )r1   rõ   rö   r   r   r   Úget_yaxis_text1_transformú  s
    


z#_AxesBase.get_yaxis_text1_transformc             C   s2   t jd }| jddt |d d| jj¡ |dfS )aË  
        Get the transformation used for drawing the secondary y-axis
        labels, which will add the given amount of padding (in points)
        between the axes and the label.  The x-direction is in axis
        coordinates and the y-direction is in data coordinates.
        Returns a 3-tuple of the form::

          (transform, valign, halign)

        where *valign* and *halign* are requested alignments for the
        text.

        .. note::

            This transformation is primarily used by the
            :class:`~matplotlib.axis.Axis` class, and is meant to be
            overridden by new kinds of projections that may need to
            place axis elements in different locations.

        zytick.alignmentrí   )r   rð   r   r™   )rñ   r   rù   r¡   rò   ró   rô   )r1   rõ   rö   r   r   r   Úget_yaxis_text2_transform  s
    


z#_AxesBase.get_yaxis_text2_transformc          	   C   s^   | j  t | j ¡ | j ¡ ¡¡ x8t| dg ƒD ](}y|j 	¡  W q. t
k
rT   Y q.X q.W d S )NÚlines)rä   rQ   r¡   rè   rD   Úget_transformrE   rÎ   Z_transformed_pathZ
invalidateÚAttributeError)r1   rR   r   r   r   rÝ   1  s    z_AxesBase._update_transScaleFc             C   s0   |r| j  ¡ S |  ¡ }|s"|  ¡  | j ¡ S dS )ae  
        Get a copy of the axes rectangle as a `.Bbox`.

        Parameters
        ----------
        original : bool
            If ``True``, return the original position. Otherwise return the
            active position. For an explanation of the positions see
            `.set_position`.

        Returns
        -------
        pos : `.Bbox`

        N)r§   r¦   Úget_axes_locatorÚapply_aspectr‹   )r1   ÚoriginalÚlocatorr   r   r   Úget_position;  s    
z_AxesBase.get_positionÚbothc             C   s   | j ||d d| _d| _dS )a  
        Set the axes position.

        Axes have two position attributes. The 'original' position is the
        position allocated for the Axes. The 'active' position is the
        position the Axes is actually drawn at. These positions are usually
        the same unless a fixed aspect is set to the Axes. See `.set_aspect`
        for details.

        Parameters
        ----------
        pos : [left, bottom, width, height] or `~matplotlib.transforms.Bbox`
            The new position of the in `.Figure` coordinates.

        which : {'both', 'active', 'original'}, optional
            Determines which position variables to change.

        )r   N)Ú_set_positionrÅ   rÆ   )r1   Úposr   r   r   r   Úset_positionS  s    z_AxesBase.set_positionc             C   s`   t |tjƒstjj|Ž }x<| j | ¡D ],}|dkr>|j |¡ |dkr&|j	 |¡ q&W d| _
dS )zÓ
        private version of set_position.  Call this internally
        to get the same functionality of `get_position`, but not
        to take the axis out of the constrained_layout
        hierarchy.
        )r  Úactive)r  r  TN)rx   r¡   ÚBboxBaser¢   r£   rÌ   rÏ   r‹   rQ   r§   Ústale)r1   r  r   Úaxr   r   r   r  l  s    z_AxesBase._set_positionc             C   s4   x.| j  | ¡D ]}|jdd}|j|dd qW dS )zÕ
        Reset the active position to the original position.

        This resets the a possible position change due to aspect constraints.
        For an explanation of the positions see `.set_position`.
        T)r  r  )r   N)rÌ   rÏ   r  r  )r1   r  r  r   r   r   Úreset_position|  s    z_AxesBase.reset_positionc             C   s   || _ d| _dS )z
        Set the axes locator.

        Parameters
        ----------
        locator : Callable[[Axes, Renderer], Bbox]
        TN)Ú_axes_locatorr
  )r1   r  r   r   r   r²   ‡  s    z_AxesBase.set_axes_locatorc             C   s   | j S )z*
        Return the axes_locator.
        )r  )r1   r   r   r   rÿ   ’  s    z_AxesBase.get_axes_locatorc             C   s<   |  | j¡ | ¡ s | | j¡ | |_|jr8| j |¡ dS )z3set the boilerplate props for artists added to axesN)	r±   ró   Zis_transform_setÚset_transformrç   r.   Z	mouseoverÚ_mouseover_setrq   )r1   Úar   r   r   Ú_set_artist_props˜  s    z_AxesBase._set_artist_propsc             C   s   t  ddd¡S )a]  
        Returns the patch used to draw the background of the axes.  It
        is also used as the clipping path for any data elements on the
        axes.

        In the standard axes, this is a rectangle, but in other
        projections it may not be.

        .. note::

            Intended to be overridden by new projection types.

        )g        g        g      ð?)rr   Ú	Rectangle)r1   r   r   r   Ú_gen_axes_patch¢  s    z_AxesBase._gen_axes_patchç        Úinchesc                s   t ‡ fdd„dD ƒƒS )ai  
        Returns a dict whose keys are spine names and values are
        Line2D or Patch instances. Each element is used to draw a
        spine of the axes.

        In the standard axes, this is a single line segment, but in
        other projections it may not be.

        .. note::

            Intended to be overridden by new projection types.

        c             3   s    | ]}|t j ˆ |¡fV  qd S )N)ÚmspinesZSpineZlinear_spine)r   Zside)r1   r   r   rb   À  s   z-_AxesBase._gen_axes_spines.<locals>.<genexpr>)r™   rš   r–   r•   )r   )r1   Z	locationsÚoffsetrG   r   )r1   r   r³   ²  s    z_AxesBase._gen_axes_spinesc             C   s,  t | dƒr| j ¡ }nd}| j ¡ }| j ¡ }| j ¡  | j ¡  x| j ¡ D ]\}}| ¡  qNW d| _t	 
¡ | _| jdk	rÚ| jjj| j_| jjj| j_| j ¡ \}}| j||d| j ¡ d t | jj ¡ | j¡| j_n4| j d¡ y|  dd¡ W n tk
r   Y nX | jdk	rx| jjj| j_| jjj| j_| j ¡ \}}	| j||	d| j ¡ d t | jj ¡ | j¡| j_n4| j d¡ y|  dd¡ W n tk
rª   Y nX td	 rÆ| j t ¡ ¡ td
 rà| j t ¡ ¡ | jdkròd| _ | jdkrd| _!td | _"td | _#d| _$d| _%|  &¡  t'| ƒ| _(t'| dƒ| _)td | _*g | _+g | _,g | _-g | _.g | _/g | _0t1ƒ | _2g | _3d| _4d| _5g | _6g | _7|  8d¡ | j8| j*td td d t9j:td td d}
t;j<ddd|
ddd| _=t;j<ddd|
 >¡ ddd| _?t;j<ddd|
 >¡ ddd| _@td }|  A|¡ d| _Bx$| j=| j?| j@fD ]}|  C|¡ qJW |  D¡ | _| j E| jF¡ | j G| jH¡ | j Id¡ | j Jd¡ | j K| jL¡ |  M¡  | j N| j¡ | j N| j¡ | jO P¡  | jQ P¡  | jr| j R|¡ | j R|¡ | jr"| j R|¡ | j R|¡ d| _SdS ) zClear the current axes.ÚpatchTNF)ÚemitrŽ   Úlinearr   r   zxtick.minor.visiblezytick.minor.visiblezaxes.xmarginzaxes.ymarginrT   z	axes.gridzaxes.grid.whichzaxes.grid.axis)r   Úaxiszaxes.titlesizezaxes.titleweight)ÚsizeZweightg      à?g      ð?r   ZbaselineÚcenter)r]   r^   ÚtextZfontpropertiesZverticalalignmentZhorizontalalignmentg        r™   rš   zaxes.titlepadr   )TÚhasattrr  rÖ   rD   rE   rº   r´   rp   Úignore_existing_data_limitsr   ZCallbackRegistryrÃ   r«   rž   r”   Úget_xlimÚset_xlimÚget_autoscalex_onÚmscaleZscale_factoryÚ	get_scaleÚ_scaleÚ
_set_scaleÚ	TypeErrorr¬   Úget_ylimÚset_ylimÚget_autoscaley_onr   Úset_minor_locatorÚmtickerÚAutoMinorLocatorÚ_autoscaleXonÚ_autoscaleYonÚ_xmarginÚ_ymarginÚ_tightÚ_use_sticky_edgesrÝ   r,   Ú
_get_linesÚ_get_patches_for_fillZ_gridOnrü   ÚpatchesÚtextsÚtablesÚartistsÚimagesr   r  Ú
child_axesÚ_current_imageÚlegend_ÚcollectionsÚ
containersrë   Úfont_managerZFontPropertiesÚmtextZTextÚtitler4   Ú_left_titleÚ_right_titleÚ_set_title_offset_transÚ_autotitleposr  r  r±   ró   Úset_facecolorr¶   Zset_edgecolorZset_linewidthr  ræ   Úset_axis_onÚset_clip_pathr­   Zcleanr¯   Úset_visibler
  )r1   Zpatch_visibleZxaxis_visibleZyaxis_visiblerH   Úspiner×   rÙ   rØ   rÚ   ZpropsÚtitle_offset_pointsÚ_titler   r   r   rº   Ã  sÚ    






















z_AxesBase.claz3.0c             C   s
   t | jƒS )N)Ú	frozensetr  )r1   r   r   r   Úmouseover_setW  s    z_AxesBase.mouseover_setc             C   s   |   ¡  dS )zClear the axes.N)rº   )r1   r   r   r   Úclear\  s    z_AxesBase.clearc             C   s
   | j  ¡ S )zGet the facecolor of the Axes.)r  Úget_facecolor)r1   r   r   r   rR  `  s    z_AxesBase.get_facecolorc             C   s   || _ d| _| j |¡S )zm
        Set the facecolor of the Axes.

        Parameters
        ----------
        color : color
        T)r¶   r
  r  rH  )r1   r(   r   r   r   rH  e  s    z_AxesBase.set_facecolorc             C   sR   t  d|d | jj¡| _x4| j| j| jfD ] }| | j	| j ¡ | 
d¡ q*W dS )z}
        Set the offset for the title either from rcParams['axes.titlepad']
        or from set_title kwarg ``pad``.
        g        rð   N)r¡   rò   ró   rô   ZtitleOffsetTransrC  rD  rE  r  ræ   Zset_clip_box)r1   rM  rN  r   r   r   rF  r  s    z!_AxesBase._set_title_offset_transc             O   sT   |r|rt dƒ‚t|ƒdkr.|d dkr.d}n
t||Ž}| j |¡ | j |¡ dS )at	  
        Set the property cycle of the Axes.

        The property cycle controls the style properties such as color,
        marker and linestyle of future plot commands. The style properties
        of data already added to the Axes are not modified.

        Call signatures::

          set_prop_cycle(cycler)
          set_prop_cycle(label=values[, label2=values2[, ...]])
          set_prop_cycle(label, values)

        Form 1 sets given `~cycler.Cycler` object.

        Form 2 creates a `~cycler.Cycler` which cycles over one or more
        properties simultaneously and set it as the property cycle of the
        axes. If multiple properties are given, their value lists must have
        the same length. This is just a shortcut for explicitly creating a
        cycler and passing it to the function, i.e. it's short for
        ``set_prop_cycle(cycler(label=values label2=values2, ...))``.

        Form 3 creates a `~cycler.Cycler` for a single property and set it
        as the property cycle of the axes. This form exists for compatibility
        with the original `cycler.cycler` interface. Its use is discouraged
        in favor of the kwarg form, i.e. ``set_prop_cycle(label=values)``.

        Parameters
        ----------
        cycler : Cycler
            Set the given Cycler. *None* resets to the cycle defined by the
            current style.

        label : str
            The property key. Must be a valid `.Artist` property.
            For example, 'color' or 'linestyle'. Aliases are allowed,
            such as 'c' for 'color' and 'lw' for 'linewidth'.

        values : iterable
            Finite-length iterable of the property values. These values
            are validated and will raise a ValueError if invalid.

        Examples
        --------
        Setting the property cycle for a single property:

        >>> ax.set_prop_cycle(color=['red', 'green', 'blue'])

        Setting the property cycle for simultaneously cycling over multiple
        properties (e.g. red circle, green plus, blue cross):

        >>> ax.set_prop_cycle(color=['red', 'green', 'blue'],
        ...                   marker=['o', '+', 'x'])

        See Also
        --------
        matplotlib.rcsetup.cycler
            Convenience function for creating validated cyclers for properties.
        cycler.cycler
            The original function for creating unvalidated cyclers.

        zCCannot supply both positional and keyword arguments to this method.r   r   N)r(  r#   r   r5  r0   r6  )r1   r=   r>   Z
prop_cycler   r   r   r0   ~  s    ?
z_AxesBase.set_prop_cyclec             C   s   | j S )N)r¨   )r1   r   r   r   Ú
get_aspectÈ  s    z_AxesBase.get_aspectc             C   s’   t |tƒr|dkst|ƒ}|r<t| j | ¡| j | ¡ ƒ}n| g}x|D ]
}||_qHW |dkrd| j}| j	||d |dk	rˆ| j
||d d| _dS )a  
        Set the aspect of the axis scaling, i.e. the ratio of y-unit to x-unit.

        Parameters
        ----------
        aspect : {'auto', 'equal'} or num
            Possible values:

            ========   ================================================
            value      description
            ========   ================================================
            'auto'     automatic; fill the position rectangle with data
            'equal'    same scaling from data to plot units for x and y
             num       a circle will be stretched such that the height
                       is num times the width. aspect=1 is the same as
                       aspect='equal'.
            ========   ================================================

        adjustable : None or {'box', 'datalim'}, optional
            If not ``None``, this defines which parameter will be adjusted to
            meet the required aspect. See `.set_adjustable` for further
            details.

        anchor : None or str or 2-tuple of float, optional
            If not ``None``, this defines where the Axes will be drawn if there
            is extra space due to aspect constraints. The most common way to
            to specify the anchor are abbreviations of cardinal directions:

            =====   =====================
            value   description
            =====   =====================
            'C'     centered
            'SW'    lower left corner
            'S'     middle of bottom edge
            'SE'    lower right corner
            etc.
            =====   =====================

            See `.set_anchor` for further details.

        share : bool, optional
            If ``True``, apply the settings to all shared Axes.
            Default is ``False``.

        See Also
        --------
        matplotlib.axes.Axes.set_adjustable
            defining the parameter to adjust in order to meet the required
            aspect.
        matplotlib.axes.Axes.set_anchor
            defining the position in case of extra space.
        )ÚequalrŽ   N)ÚshareT)rx   r   ÚfloatrQ   r­   rÏ   r¯   r¨   r©   Úset_adjustableÚ
set_anchorr
  )r1   ÚaspectÚ
adjustableÚanchorrU  r.   r  r   r   r   Ú
set_aspectË  s    5

z_AxesBase.set_aspectc             C   s   | j S )N)r©   )r1   r   r   r   Úget_adjustable  s    z_AxesBase.get_adjustablec             C   sn   |dkrt jdddd |dkr(tdƒ‚|rJt| j | ¡| j | ¡ ƒ}n| g}x|D ]
}||_qVW d| _dS )	a†  
        Define which parameter the Axes will change to achieve a given aspect.

        Parameters
        ----------
        adjustable : {'box', 'datalim'}
            If 'box', change the physical dimensions of the Axes.
            If 'datalim', change the ``x`` or ``y`` data limits.

        share : bool, optional
            If ``True``, apply the settings to all shared Axes.
            Default is ``False``.

        See Also
        --------
        matplotlib.axes.Axes.set_aspect
            for a description of aspect handling.

        Notes
        -----
        Shared Axes (of which twinned Axes are a special case)
        impose restrictions on how aspect ratios can be imposed.
        For twinned Axes, use 'datalim'.  For Axes that share both
        x and y, use 'box'.  Otherwise, either 'datalim' or 'box'
        may be used.  These limitations are partly a requirement
        to avoid over-specification, and partly a result of the
        particular implementation we are currently using, in
        which the adjustments for aspect ratios are done sequentially
        and independently on each Axes as it is drawn.
        z
box-forcedz2.2zkeyword argument)Úobj_type)r   Údatalimz
box-forcedz$argument must be 'box', or 'datalim'TN)	r   rz   r    rQ   r­   rÏ   r¯   r©   r
  )r1   rZ  rU  r.   r  r   r   r   rW    s    

z_AxesBase.set_adjustablec             C   s   | j S )zü
        Get the anchor location.

        See Also
        --------
        matplotlib.axes.Axes.set_anchor
            for a description of the anchor.
        matplotlib.axes.Axes.set_aspect
            for a description of aspect handling.
        )rª   )r1   r   r   r   Ú
get_anchorB  s    z_AxesBase.get_anchorc             C   st   |t jjks.t|ƒdks.tdd t jj¡ ƒ‚|rPt| j | ¡| j	 | ¡ ƒ}n| g}x|D ]
}||_
q\W d| _dS )ak  
        Define the anchor location.

        The actual drawing area (active position) of the Axes may be smaller
        than the Bbox (original position) when a fixed aspect is required. The
        anchor defines where the drawing area will be located within the
        available space.

        Parameters
        ----------
        anchor : 2-tuple of floats or {'C', 'SW', 'S', 'SE', ...}
            The anchor position may be either:

            - a sequence (*cx*, *cy*). *cx* and *cy* may range from 0
              to 1, where 0 is left or bottom and 1 is right or top.

            - a string using cardinal directions as abbreviation:

              - 'C' for centered
              - 'S' (south) for bottom-center
              - 'SW' (south west) for bottom-left
              - etc.

              Here is an overview of the possible positions:

              +------+------+------+
              | 'NW' | 'N'  | 'NE' |
              +------+------+------+
              | 'W'  | 'C'  | 'E'  |
              +------+------+------+
              | 'SW' | 'S'  | 'SE' |
              +------+------+------+

        share : bool, optional
            If ``True``, apply the settings to all shared Axes.
            Default is ``False``.

        See Also
        --------
        matplotlib.axes.Axes.set_aspect
            for a description of aspect handling.
        rV   zargument must be among %sz, TN)r¡   r¢   Zcoefsr#   r    r®   rQ   r­   rÏ   r¯   rª   r
  )r1   r[  rU  r.   r  r   r   r   rX  O  s    +

z_AxesBase.set_anchorc             C   sD   |   ¡ \}}|  ¡ \}}tt|| ƒdƒ}tt|| ƒdƒ}|| S )zŽ
        Returns the aspect ratio of the raw data.

        This method is intended to be overridden by new projection
        types.
        g ÂëþKH´9)Ú
get_xboundÚ
get_yboundr|   Úabs)r1   ÚxminÚxmaxÚyminÚymaxÚxsizeÚysizer   r   r   Úget_data_ratio‡  s
    z_AxesBase.get_data_ratioc             C   s\   |   ¡ \}}|  ¡ \}}ttt |¡t |¡ ƒdƒ}ttt |¡t |¡ ƒdƒ}|| S )z
        Returns the aspect ratio of the raw data in log scale.
        Will be used when both axis scales are in log.
        g ÂëþKH´9)ra  rb  r|   rc  ÚmathÚlog10)r1   rd  re  rf  rg  rh  ri  r   r   r   Úget_data_ratio_log–  s
    z_AxesBase.get_data_ratio_logc       0      C   s  |dkr| j dd}|  ¡ }| jdkrª|  ¡ |  ¡  }}|dkrN|dkrNd}q®|dkrd|dkrdd}q®|dkrt|dks„|dkr®|dkr®|dkr¨tjd||f d	d
 d}q®nd}|dkrÈ| j|dd dS |dkrÖd}n|}|  ¡  	¡ \}}|| }	| j
dkrh| | jkrtdƒ‚|dkr*||  ¡  }
n||  ¡  }
| ¡ }| |
||	¡}|  | |  ¡ |¡d¡ dS | j|dd |  ¡ \}}|  ¡ \}}|dkrÄt |¡t |¡ }}t |¡t |¡ }}tt|| ƒdƒ}tt|| ƒdƒ}|j\}}}}|	||  }
|
| }|| | d }t|ƒdk r,dS |dkr~| j}t |j¡t |j¡ }t |j¡t |j¡ }d| }d| }n| j}d|j }d|j  }|| }|| }|| } || }!|!| }"| | }#d}$d}%| | j!k}&| | j"k}'|&rø|'røtdƒ‚|'rd}(nN||$kr@||%kr@|#dkr,|dk p<|"dk o<|dk})n|dk})|&pP|)}(|(r®d||  }*|*| d  }+|*| d  },|dkrž|  #d|+ d|, f¡ n|  #|+|,f¡ nTd||  }-|-|!d  }.|-|!d  }/|dkrô|  $d|. d|/ f¡ n|  $|.|/f¡ dS )aP  
        Adjust the Axes for a specified data aspect ratio.

        Depending on `.get_adjustable` this will modify either the Axes box
        (position) or the view limits. In the former case, `.get_anchor`
        will affect the position.

        Notes
        -----
        This is called automatically when each Axes is drawn.  You may need
        to call it yourself if you need to update the Axes position and/or
        view limits before the Figure is drawn.

        See Also
        --------
        matplotlib.axes.Axes.set_aspect
            for a description of aspect ratio handling.
        matplotlib.axes.Axes.set_adjustable
            defining the parameter to adjust in order to meet the required
            aspect.
        matplotlib.axes.Axes.set_anchor
            defining the position in case of extra space.
        NT)r  r@   r  ÚlogrŽ   z:aspect is not supported for Axes with xscale=%s, yscale=%srV   )Ú
stacklevelr  )r   rT  r   )r   z
box-forcedzJAdjustable 'box' is not allowed in a twinned Axes.  Use 'datalim' instead.g ÂëþKH´9g      ð?g{®Gázt?gÍÌÌÌÌÌð?r   z>adjustable='datalim' is not allowed when both axes are shared.Fg      à?g       @g      $@)%r  rS  rH   Ú
get_xscaleÚ
get_yscaleÚwarningsÚwarnr  Z
get_figureZget_size_inchesr©   rÌ   ÚRuntimeErrorrm  rj  r¦   Zshrunk_to_aspectZanchoredr`  ra  rb  rk  rl  r|   rc  rŒ   rà   rÙ   r×   rÚ   rØ   r¤   r¥   r­   r¯   Ú
set_yboundÚ
set_xbound)0r1   ZpositionrY  rÊ   rË   Zaspect_scale_modeÚAZfigWZfigHZ
fig_aspectZ
box_aspectZpbZpb1rd  re  rf  rg  rh  ri  ÚlÚbÚwÚhZ
data_ratioZ
y_expanderZdLZdL_widthZ	dL_heightZxrZyrZxmargZymargZYsizeZXsizeZXmargZYmargZxmZymZshared_xZshared_yZadjust_yZadjyZycrØ   rÚ   Zxcr×   rÙ   r   r   r   r   £  s¶    











z_AxesBase.apply_aspectc          	   O   s6  t |ƒt |ƒ  krdkrDn n$|  ¡ \}}|  ¡ \}}||||fS | dd¡}t |ƒdkrt|d tƒr|d  ¡ }|dkrŽ|  ¡  nj|dkr¢|  ¡  nV|dkrì|  	d¡ |  
d¡ | jd	d
 |dkræ| j
ddd qø|dkr| j
dddd |  	d	¡ nÞ|dkr.| jdd
 |  	d	¡ n¼|dkr`| jdd
 |  	d	¡ | j
dddd nŠ|dkrø| j
dddd |  	d	¡ |  ¡ }	|  ¡ }
tt |	¡t |
¡ƒ}| j|	d |	d | g|d	d | j|
d |
d | g|d	d ntd| ƒ‚|  ¡ \}}|  ¡ \}}||||fS y|d  W n² tk
rÚ   | dd¡}| dd¡}d	}|dkrn|dkrnd}| j||||d\}}| dd¡}| dd¡}d	}|dkr¸|dkr¸d}| j||||d\}}||||fS X |d }t |ƒdkrútdƒ‚| j|d |d g|d	d | j|d |d g|d	d |S ) a¬  
        Convenience method to get or set some axis properties.

        Call signatures::

          xmin, xmax, ymin, ymax = axis()
          xmin, xmax, ymin, ymax = axis(xmin, xmax, ymin, ymax)
          xmin, xmax, ymin, ymax = axis(option)
          xmin, xmax, ymin, ymax = axis(**kwargs)

        Parameters
        ----------
        xmin, ymin, xmax, ymax : float, optional
            The axis limits to be set. Either none or all of the limits must
            be given.

        option : str
            Possible values:

            ======== ==========================================================
            Value    Description
            ======== ==========================================================
            'on'     Turn on axis lines and labels.
            'off'    Turn off axis lines and labels.
            'equal'  Set equal scaling (i.e., make circles circular) by
                     changing axis limits.
            'scaled' Set equal scaling (i.e., make circles circular) by
                     changing dimensions of the plot box.
            'tight'  Set limits just large enough to show all data.
            'auto'   Automatic scaling (fill plot box with data).
            'normal' Same as 'auto'; deprecated.
            'image'  'scaled' with axis limits equal to data limits.
            'square' Square plot; similar to 'scaled', but initially forcing
                     ``xmax-xmin = ymax-ymin``.
            ======== ==========================================================

        emit : bool, optional, default *True*
            Whether observers are notified of the axis limit change.
            This option is passed on to `~.Axes.set_xlim` and
            `~.Axes.set_ylim`.

        Returns
        -------
        xmin, xmax, ymin, ymax : float
            The axis limits.

        See also
        --------
        matplotlib.axes.Axes.set_xlim
        matplotlib.axes.Axes.set_ylim
        r   r  Tr   ZonZoff)rT  ÚtightÚscaledZnormalrŽ   ÚimageÚsquarerŽ   F)r|  rT  r_  )rZ  r}  r   r   )rZ  r[  r|  r~  r  )r  rŽ   z-Unrecognized string %s to axis; try on or offrd  Nre  rf  rg  é   z$v must contain [xmin xmax ymin ymax]rV   rv   )r#   r!  r)  r`   rx   r   ÚlowerrI  Úset_axis_offÚset_autoscale_onr\  Úautoscale_viewr|   r\   Zdiffr"  r*  r    Ú
IndexError)r1   rs   r>   rd  re  rf  rg  r  ÚsZxlimZylimZ	edge_sizerŽ   r   r   r   r  :  s€    5 









z_AxesBase.axisc             C   s   | j S )z>Return the `Legend` instance, or None if no legend is defined.)r>  )r1   r   r   r   Ú
get_legendº  s    z_AxesBase.get_legendc             C   s   t  d| j¡S )z2return a list of Axes images contained by the AxesZ	AxesImage)r   Úsilent_listr;  )r1   r   r   r   Ú
get_images¾  s    z_AxesBase.get_imagesc             C   s   t  d| j¡S )z,Return a list of lines contained by the Axesrk   )r   rˆ  rü   )r1   r   r   r   Ú	get_linesÂ  s    z_AxesBase.get_linesc             C   s   | j S )zReturn the XAxis instance.)rD   )r1   r   r   r   Ú	get_xaxisÆ  s    z_AxesBase.get_xaxisc             C   s   t  d| j ¡ ¡S )z5Get the x grid lines as a list of `Line2D` instances.zLine2D xgridline)r   rˆ  rD   Úget_gridlines)r1   r   r   r   Úget_xgridlinesÊ  s    z_AxesBase.get_xgridlinesc             C   s   t  d| j ¡ ¡S )z5Get the x tick lines as a list of `Line2D` instances.zLine2D xtickline)r   rˆ  rD   Úget_ticklines)r1   r   r   r   Úget_xticklinesÏ  s    z_AxesBase.get_xticklinesc             C   s   | j S )zReturn the YAxis instance.)rE   )r1   r   r   r   Ú	get_yaxisÔ  s    z_AxesBase.get_yaxisc             C   s   t  d| j ¡ ¡S )z5Get the y grid lines as a list of `Line2D` instances.zLine2D ygridline)r   rˆ  rE   rŒ  )r1   r   r   r   Úget_ygridlinesØ  s    z_AxesBase.get_ygridlinesc             C   s   t  d| j ¡ ¡S )z5Get the y tick lines as a list of `Line2D` instances.zLine2D ytickline)r   rˆ  rE   rŽ  )r1   r   r   r   Úget_yticklinesÝ  s    z_AxesBase.get_yticklinesc             C   sN   t |tjjƒr(|jd | jkrDtdƒ‚n|| jkrD|| jkrDtdƒ‚|| _dS )zêSet the current image.

        This image will be the target of colormap functions like
        `~.pyplot.viridis`, and other functions such as `~.pyplot.clim`.  The
        current image is an attribute of the current axes.
        r   z"ContourSet must be in current AxeszAArgument must be an image, collection, or ContourSet in this AxesN)rx   rñ   ZcontourZ
ContourSetr?  r    r;  r=  )r1   Zimr   r   r   Ú_sciä  s    
z_AxesBase._scic             C   s   | j S )zZ
        Helper for :func:`~matplotlib.pyplot.gci`;
        do not use elsewhere.
        )r=  )r1   r   r   r   Ú_gció  s    z_AxesBase._gcic             C   s,   t | jƒt | jƒ t | jƒ t | jƒ dkS )zÜ
        Return *True* if any artists have been added to axes.

        This should not be used to determine whether the *dataLim*
        need to be updated, and may not actually be useful for
        anything.
        r   )r#   r?  r;  rü   r7  )r1   r   r   r   Úhas_dataú  s    z_AxesBase.has_datac             C   s<   | |_ | j |¡ | jj|_|  |¡ | | j¡ d| _|S )a  Add any :class:`~matplotlib.artist.Artist` to the axes.

        Use `add_artist` only for artists for which there is no dedicated
        "add" method; and if necessary, use a method such as `update_datalim`
        to manually update the dataLim if the artist is to be included in
        autoscaling.

        If no ``transform`` has been specified when creating the artist (e.g.
        ``artist.get_transform() == None``) then the transform is set to
        ``ax.transData``.

        Returns the artist.
        T)	r.   r:  r}   ÚremoveÚ_remove_methodr  rJ  r  r
  )r1   r  r   r   r   Ú
add_artist  s    

z_AxesBase.add_artistc             C   s.   | |_ tj|_| j |¡ | jj|_d| _|S )zÈ
        Add a :class:`~matplotlib.axes.Axesbase` instance
        as a child to the axes.

        Returns the added axes.

        This is the lowlevel version.  See `.axes.Axes.inset_axes`
        T)	Z_axesrŸ   Z_stale_axes_callbackZstale_callbackr<  r}   r–  r—  r
  )r1   r  r   r   r   Úadd_child_axes  s    
z_AxesBase.add_child_axesc             C   sx   |  ¡ }|s | dt| jƒ ¡ | j |¡ | jj|_|  |¡ | ¡ dkrX| 	| j
¡ |rn|  | | j¡¡ d| _|S )z‚
        Add a :class:`~matplotlib.collections.Collection` instance
        to the axes.

        Returns the collection.
        z_collection%dNT)r   r°   r#   r?  r}   r–  r—  r  Úget_clip_pathrJ  r  Úupdate_datalimZget_datalimrç   r
  )r1   Z
collectionZautolimrw   r   r   r   Úadd_collection3  s    

z_AxesBase.add_collectionc             C   sF   |   |¡ | ¡ s&| dt| jƒ ¡ | j |¡ | jj|_d| _|S )ze
        Add a :class:`~matplotlib.image.AxesImage` to the axes.

        Returns the image.
        z_image%dT)	r  r   r°   r#   r;  r}   r–  r—  r
  )r1   r~  r   r   r   Ú	add_imageJ  s    

z_AxesBase.add_imagec             C   s,   |  ¡ \}}}}| j ||f||ff¡ d S )N)Z
get_extentr.   r›  )r1   r~  rd  re  rf  rg  r   r   r   Ú_update_image_limitsX  s    z_AxesBase._update_image_limitsc             C   sh   |   |¡ | ¡ dkr"| | j¡ |  |¡ | ¡ sH| dt| jƒ ¡ | j 	|¡ | jj
|_d| _|S )zv
        Add a :class:`~matplotlib.lines.Line2D` to the list of plot
        lines

        Returns the line.
        Nz_line%dT)r  rš  rJ  r  Ú_update_line_limitsr   r°   r#   rü   r}   r–  r—  r
  )r1   rR   r   r   r   Úadd_line\  s    


z_AxesBase.add_linec             C   s*   |   |¡ | j |¡ | jj|_d| _|S )z


        T)r  r8  r}   r–  r—  r
  )r1   Ztxtr   r   r   Ú	_add_texto  s
    

z_AxesBase._add_textc             C   s¾   |  ¡ }|jjdkrdS | ¡ }|| jkr0|}nRt| | j¡ƒr~|| j }| jjrr| ¡ }| 	¡ \}}| 
|¡}q‚| |¡}n|}|jjdkrº| | j¡\}	}
| jj|| j|	|
d d| _dS )zV
        Figures out the data limit of the given line, updating self.dataLim.
        r   N)ÚupdatexÚupdateyF)Úget_pathÚverticesr  rý   rç   rd   Úcontains_branch_seperatelyZ	is_affineZ_get_transformed_pathZget_transformed_path_and_affineZtransform_path_affineZtransform_pathrà   Zupdate_from_pathr   )r1   rR   ÚpathZ
line_transZ	data_pathZtrans_to_dataZline_trans_pathZna_pathÚ_r¢  r£  r   r   r   rŸ  y  s,    

z_AxesBase._update_line_limitsc             C   sF   |   |¡ | ¡ dkr"| | j¡ |  |¡ | j |¡ | jj|_|S )a  
        Add a :class:`~matplotlib.patches.Patch` *p* to the list of
        axes patches; the clipbox will be set to the Axes clipping
        box.  If the transform is not set, it will be set to
        :attr:`transData`.

        Returns the patch.
        N)	r  rš  rJ  r  Ú_update_patch_limitsr7  r}   r–  r—  )r1   rg   r   r   r   Ú	add_patch¥  s    



z_AxesBase.add_patchc             C   s   t |tjƒr | ¡ s | ¡ s dS | ¡ j}|jdkrŒ| ¡  	|¡}| 
¡ | jkrh| 
¡ | j }| 	|¡}| ¡  | j¡\}}| j|||d dS )z$update the data limits for patch *p*Nr   )r¢  r£  )rx   rr   r  Z	get_widthZ
get_heightr¤  r¥  r  Zget_patch_transformÚ	transformZget_data_transformrç   rý   r¦  r›  )r1   r  r¥  ÚxysZpatch_to_datar¢  r£  r   r   r   r©  ·  s    



z_AxesBase._update_patch_limitsc             C   s0   |   |¡ | j |¡ | | j¡ | jj|_|S )a  
        Add a :class:`~matplotlib.table.Table` instance to the
        list of axes tables

        Parameters
        ----------
        tab: `matplotlib.table.Table`
            Table instance

        Returns
        -------
        `matplotlib.table.Table`: the table.
        )r  r9  r}   rJ  r  r–  r—  )r1   Ztabr   r   r   Ú	add_tableÑ  s
    

z_AxesBase.add_tablec             C   s:   |  ¡ }|s | dt| jƒ ¡ | j |¡ | jj|_|S )z
        Add a :class:`~matplotlib.container.Container` instance
        to the axes.

        Returns the collection.
        z_container%d)r   r°   r#   r@  r}   r–  r—  )r1   Z	containerrw   r   r   r   Úadd_containerå  s    
z_AxesBase.add_containerc             C   s   |   ¡  | j||d dS )z‚
        Callback for processing changes to axis units.

        Currently forces updates of data limits and view limits.
        )r   r“   N)Úrelimr„  )r1   r   r“   r   r   r   r‘   ó  s    z_AxesBase._on_units_changedc             C   sž   | j  d¡ | j  tj ¡  ¡ ¡ d| _x$| jD ]}|r@| 	¡ r0|  
|¡ q0W x$| jD ]}|rf| 	¡ rV|  |¡ qVW x$| jD ]}|rŒ| 	¡ r||  |¡ q|W dS )a  
        Recompute the data limits based on current artists. If you want to
        exclude invisible artists from the calculation, set
        ``visible_only=True``

        At present, :class:`~matplotlib.collections.Collection`
        instances are not supported.
        TN)rà   re   Z
set_pointsr¡   r¢   rß   Ú
get_pointsr   rü   rÖ   rŸ  r7  r©  r;  rž  )r1   Zvisible_onlyrR   rg   r~  r   r   r   r¯  ü  s    z_AxesBase.relimc             C   s6   t  |¡}t|ƒsdS | jj|| j||d d| _dS )as  
        Extend the `~.Axes.dataLim` BBox to include the given points.

        If no data is set currently, the BBox will ignore its limits and set
        the bound to be the bounds of the xydata (*xys*). Otherwise, it will
        compute the bounds of the union of its current data and the data in
        *xys*.

        Parameters
        ----------
        xys : 2D array-like
            The points to include in the data limits BBox. This can be either
            a list of (x, y) tuples or a Nx2 array.

        updatex, updatey : bool, optional, default *True*
            Whether to update the x/y limits.
        N)r¢  r£  F)r\   Zasarrayr#   rà   Zupdate_from_data_xyr   )r1   r¬  r¢  r£  r   r   r   r›    s    

z_AxesBase.update_datalimc             C   s   | j  tj | j |g¡¡ dS )zÄ
        Extend the `~.Axes.datalim` BBox to include the given
        `~matplotlib.transforms.Bbox`.

        Parameters
        ----------
        bounds : `~matplotlib.transforms.Bbox`
        N)rà   rQ   r¡   r¢   Úunion)r1   rŒ   r   r   r   Úupdate_datalim_bounds0  s    	z_AxesBase.update_datalim_boundsc                s0   ‡ fdd„}||ˆ j d|ƒ}||ˆ jd|ƒ}|S )zALook for unit *kwargs* and update the axis instances as necessaryc                sŠ   |d kr|S | d k	r&|  ¡ s&| | ¡ |d k	r†| ||j¡}ˆ jdkr`dddœ}| || |¡}||jkr†| |¡ | d k	r†| | ¡ |S )Nr@   rA   rC   )r?   rB   )Z
have_unitsrW   rF   rG   rH   rI   )Údatar  Z	unit_namer>   rG   Zpolar_units)r1   r   r   Ú_process_single_axis>  s    





z:_AxesBase._process_unit_info.<locals>._process_single_axisr?   rB   )rD   rE   )r1   ÚxdataÚydatar>   r´  r   )r1   r   Ú_process_unit_info;  s    z_AxesBase._process_unit_infoc             C   s   | j  |¡d S )zd
        Return *True* if the given *mouseevent* (in display coords)
        is in the Axes
        r   )r  Úcontains)r1   Ú
mouseeventr   r   r   Úin_axes[  s    z_AxesBase.in_axesc             C   s   | j o
| jS )zS
        Get whether autoscaling is applied for both axes on plot commands
        )r/  r0  )r1   r   r   r   Úget_autoscale_onb  s    z_AxesBase.get_autoscale_onc             C   s   | j S )zT
        Get whether autoscaling for the x-axis is applied on plot commands
        )r/  )r1   r   r   r   r#  h  s    z_AxesBase.get_autoscalex_onc             C   s   | j S )zT
        Get whether autoscaling for the y-axis is applied on plot commands
        )r0  )r1   r   r   r   r+  n  s    z_AxesBase.get_autoscaley_onc             C   s   || _ || _dS )z}
        Set whether autoscaling is applied on plot commands

        Parameters
        ----------
        b : bool
        N)r/  r0  )r1   ry  r   r   r   rƒ  t  s    z_AxesBase.set_autoscale_onc             C   s
   || _ dS )zŒ
        Set whether autoscaling for the x-axis is applied on plot commands

        Parameters
        ----------
        b : bool
        N)r/  )r1   ry  r   r   r   Úset_autoscalex_on  s    z_AxesBase.set_autoscalex_onc             C   s
   || _ dS )zŒ
        Set whether autoscaling for the y-axis is applied on plot commands

        Parameters
        ----------
        b : bool
        N)r0  )r1   ry  r   r   r   Úset_autoscaley_on‰  s    z_AxesBase.set_autoscaley_onc             C   s   | j S )aÌ  
        When autoscaling, whether to obey all `Artist.sticky_edges`.

        Default is ``True``.

        Setting this to ``False`` ensures that the specified margins
        will be applied, even if the plot includes an image, for
        example, which would otherwise force a view limit to coincide
        with its data limit.

        The changing this property does not change the plot until
        `autoscale` or `autoscale_view` is called.
        )r4  )r1   r   r   r   Úuse_sticky_edges“  s    z_AxesBase.use_sticky_edgesc             C   s   t |ƒ| _d S )N)Úboolr4  )r1   ry  r   r   r   r¾  ¤  s    c             C   s    |dkrt dƒ‚|| _d| _dS )aB  
        Set padding of X data limits prior to autoscaling.

        *m* times the data interval will be added to each
        end of that interval before it is used in autoscaling.
        For example, if your data is in the range [0, 2], a factor of
        ``m = 0.1`` will result in a range [-0.2, 2.2].

        Negative values -0.5 < m < 0 will result in clipping of the data range.
        I.e. for a data range [0, 2], a factor of ``m = -0.1`` will result in
        a range [0.2, 1.8].

        Parameters
        ----------
        m : float greater than -0.5
        g      à¿z margin must be greater than -0.5TN)r    r1  r
  )r1   Úmr   r   r   Úset_xmargin©  s    z_AxesBase.set_xmarginc             C   s    |dkrt dƒ‚|| _d| _dS )aB  
        Set padding of Y data limits prior to autoscaling.

        *m* times the data interval will be added to each
        end of that interval before it is used in autoscaling.
        For example, if your data is in the range [0, 2], a factor of
        ``m = 0.1`` will result in a range [-0.2, 2.2].

        Negative values -0.5 < m < 0 will result in clipping of the data range.
        I.e. for a data range [0, 2], a factor of ``m = -0.1`` will result in
        a range [0.2, 1.8].

        Parameters
        ----------
        m : float greater than -0.5
        g      à¿z margin must be greater than -0.5TN)r    r2  r
  )r1   rÀ  r   r   r   Úset_ymargin¿  s    z_AxesBase.set_ymargin)r]   r^   r|  c            G   sÒ   |r|dk	r|dk	rt dƒ‚n<t|ƒdkr8|d  }}n"t|ƒdkrN|\}}n|rZt dƒ‚|dkr’|dkr’|dk	r†tjd|f dd	 | j| jfS |dk	r¤|  |¡ |dk	r¶|  |¡ | j||dk	|dk	d
 dS )aš  
        Set or retrieve autoscaling margins.

        The padding added to each limit of the axes is the *margin*
        times the data interval. All input parameters must be floats
        within the range [0, 1]. Passing both positional and keyword
        arguments is invalid and will raise a TypeError. If no
        arguments (positional or otherwise) are provided, the current
        margins will remain in place and simply be returned.

        Specifying any margin changes only the autoscaling; for example,
        if *xmargin* is not None, then *xmargin* times the X data
        interval will be added to each end of that interval before
        it is used in autoscaling.

        Parameters
        ----------
        args : float, optional
            If a single positional argument is provided, it specifies
            both margins of the x-axis and y-axis limits. If two
            positional arguments are provided, they will be interpreted
            as *xmargin*, *ymargin*. If setting the margin on a single
            axis is desired, use the keyword arguments described below.

        x, y : float, optional
            Specific margin values for the x-axis and y-axis,
            respectively. These cannot be used with positional
            arguments, but can be used individually to alter on e.g.,
            only the y-axis.

        tight : bool, default is True
            The *tight* parameter is passed to :meth:`autoscale_view`,
            which is executed after a margin is changed; the default
            here is *True*, on the assumption that when margins are
            specified, no additional padding to match tick marks is
            usually desired.  Set *tight* to *None* will preserve
            the previous setting.


        Returns
        -------
        xmargin, ymargin : float

        Notes
        -----
        If a previously used Axes method such as :meth:`pcolor` has set
        :attr:`use_sticky_edges` to `True`, only the limits not set by
        the "sticky artists" will be modified. To force all of the
        margins to be set, set :attr:`use_sticky_edges` to `False`
        before calling :meth:`margins`.

        NzACannot pass both positional and keyword arguments for x and/or y.r   r   rV   zVMust pass a single positional argument for all margins, or one for each margin (x, y).Tzignoring tight=%r in get mode)ro  )r|  r   r“   )	r(  r#   rr  rs  r1  r2  rÁ  rÂ  r„  )r1   r]   r^   r|  Úmarginsr   r   r   rÃ  Õ  s&    6



z_AxesBase.marginsc             C   s   || _ d| _dS )zÐ
        Parameters
        ----------
        z : float or None
            zorder below which artists are rasterized.  ``None`` means that
            artists do not get rasterized based on zorder.
        TN)r¹   r
  )r1   Úzr   r   r   Úset_rasterization_zorder%	  s    z"_AxesBase.set_rasterization_zorderc             C   s   | j S )z?Return the zorder value below which artists will be rasterized.)r¹   )r1   r   r   r   Úget_rasterization_zorder0	  s    z"_AxesBase.get_rasterization_zorderc             C   sz   |dkrd}d}n8d}d}|dkr2t |ƒ| _| j}|dkrJt |ƒ| _| j}|rX|rXd| _|rf|rfd| _| j|||d dS )aÝ  
        Autoscale the axis view to the data (toggle).

        Convenience method for simple axis view autoscaling.
        It turns autoscaling on or off, and then,
        if autoscaling for either axis is on, it performs
        the autoscaling on the specified axis or axes.

        Parameters
        ----------
        enable : bool or None, optional
            True (default) turns autoscaling on, False turns it off.
            None leaves the autoscaling state unchanged.

        axis : {'both', 'x', 'y'}, optional
            which axis to operate on; default is 'both'

        tight: bool or None, optional
            If True, set view limits to data limits;
            if False, let the locator and margins expand the view limits;
            if None, use tight scaling if the only artist is an image,
            otherwise treat *tight* as False.
            The *tight* setting is retained for future autoscaling
            until it is explicitly changed.

        NTF)r]   r  )r^   r  r   )r|  r   r“   )r¿  r/  r0  r1  r2  r„  )r1   Úenabler  r|  r   r“   r   r   r   Ú	autoscale4	  s     

z_AxesBase.autoscalec          
      sú   |dk	rt |ƒˆ _ˆ jrœˆ js$ˆ jrœdd„ ˆ  ¡ D ƒ}tdd„ |D ƒg ƒ}tdd„ |D ƒg ƒ}ˆ  ¡  ¡ dkr|dd„ |D ƒ}ˆ  	¡  ¡ dkr¦dd„ |D ƒ}n
g g  }}‡ fd	d
„}||ˆ j
ˆ jddˆ jˆ j|ˆ jƒ	 ||ˆ jˆ jddˆ jˆ j|ˆ jƒ	 dS )aë  
        Autoscale the view limits using the data limits.

        You can selectively autoscale only a single axis, e.g., the xaxis by
        setting *scaley* to *False*.  The autoscaling preserves any
        axis direction reversal that has already been done.

        If *tight* is *False*, the axis major locator will be used
        to expand the view limits if rcParams['axes.autolimit_mode']
        is 'round_numbers'.  Note that any margins that are in effect
        will be applied first, regardless of whether *tight* is
        *True* or *False*.  Specifying *tight* as *True* or *False*
        saves the setting as a private attribute of the Axes; specifying
        it as *None* (the default) applies the previously saved value.

        The data limits are not updated automatically when artist data are
        changed after the artist has been added to an Axes instance.  In that
        case, use :meth:`matplotlib.axes.Axes.relim` prior to calling
        autoscale_view.
        Nc             S   s   g | ]
}|j ‘qS r   )Zsticky_edges)r   Úartistr   r   r   r   z	  s    z,_AxesBase.autoscale_view.<locals>.<listcomp>c             S   s   g | ]
}|j ‘qS r   )r]   )r   Ústickyr   r   r   r   {	  s    c             S   s   g | ]
}|j ‘qS r   )r^   )r   rÊ  r   r   r   r   |	  s    rn  c             S   s   g | ]}|d kr|‘qS )r   r   )r   Úxsr   r   r   r   ~	  s    c             S   s   g | ]}|d kr|‘qS )r   r   )r   Úysr   r   r   r   €	  s    c	          	      s¾  | r|sd S |  ˆ¡}	dd„ |	D ƒ}
dd„ |
D ƒ‰ tˆ ƒrv‡ fdd„|
D ƒ}‡ fdd„|
D ƒ}ˆ }
|
 |¡ |
 |¡ tj |
¡}t||ƒ\}}| ¡ }y| ||¡\}}W n* t	k
rÖ   tj||ddd\}}Y nX t||ƒ}| 
¡ }| ¡ }t t ||¡¡ }t t ||¡¡ }|j |||¡\}}| ||g¡\}}t |¡rft |¡rf|| | }nd	}|rx||8 }|r†||7 }| ||g¡\}}ˆjs°| ||¡\}}|||ƒ d S )
Nc             S   s   g | ]
}|j ‘qS r   )rà   )r   r  r   r   r   r   ‹	  s    zH_AxesBase.autoscale_view.<locals>.handle_single_axis.<locals>.<listcomp>c             S   s   g | ]}t  |¡ ¡ r|‘qS r   )r\   Úisfiniterc   )r   Údr   r   r   r   	  s    c                s(   g | ] }t  |j¡ ¡ r|ˆ kr|‘qS r   )r\   rÍ  Ú	intervalxrc   )r   rÎ  )Ú	finite_dlr   r   r   ‘	  s    c                s(   g | ] }t  |j¡ ¡ r|ˆ kr|‘qS r   )r\   rÍ  Ú	intervalyrc   )r   rÎ  )rÐ  r   r   r   ”	  s    Fgš™™™™™©?)Ú
increasingZexpanderr   )rÏ   r#   Úextendr¡   r	  r±  rÎ   Úget_major_locatorÚnonsingularrþ   rý   Úinvertedr\   rd   Úiscloser&  Úlimit_range_for_scaler«  rÍ  r3  Zview_limits)ÚscaleZautoscaleonZshared_axesZintervalZminposr  ZmarginÚstickiesZ	set_boundZsharedZdlZx_finiteZy_finiteÚbbr×   rÙ   r  r«  Zinverse_transZdo_lower_marginZdo_upper_marginZx0tZx1tZdelta)r1   )rÐ  r   Úhandle_single_axis„	  sJ    



z4_AxesBase.autoscale_view.<locals>.handle_single_axisrÏ  ZminposxrÑ  Zminposy)r¿  r3  r¾  r1  r2  Úget_childrenÚsumrp  r  rq  r/  r­   rD   rv  r0  r¯   rE   ru  )r1   r|  r   r“   rÚ  Z
x_stickiesZ
y_stickiesrÜ  r   )r1   r   r„  a	  s$    

@z_AxesBase.autoscale_viewc             C   s   | j | jfS )N)rD   rE   )r1   r   r   r   Ú_get_axis_listË	  s    z_AxesBase._get_axis_listc          
   C   s<  t  d¡ | jdk	r(| js(t  d¡ dS | j| j| jf}| jdkr„x:|D ]2}| ¡ \}}t |d¡sHd| _t  d|¡ dS qHW d| _x²|D ]ª}| ¡ \}}d}| j	 
| ¡}xz|D ]r}yV|j ¡ dksÔ|j ¡ dkr|j |¡}	|	j}
| j ¡  d	|
f¡d
 }t||ƒ}W q° tk
r    Y q°X q°W | ||f¡ qŠW dS )z‰
        Update the title position based on the bounding box enclosing
        all the ticklabels and x-axis spine and xlabel...
        Zupdate_title_posNz2title position was updated manually, not adjustingg      ð?FzEnot adjusting title pos because title was already placed manually: %fTr•   g        r   )Ú_logÚdebugrG  rC  rD  rE  r  r\   r×  rÌ   rÏ   rD   Zget_label_positionZget_ticks_positionÚget_tightbboxrg  ræ   rÖ  r«  r|   rþ   r  )r1   ÚrendererZtitlesrC  r]   r^   rØ   Zaxsr  rÛ  r•   Zynr   r   r   Ú_update_title_positionÎ	  s:    






z _AxesBase._update_title_positionc       
         sî  |dkrˆj }|dkrtdƒ‚ˆ ¡ s*dS | d¡ dˆ_ˆ ¡ }|r\|ˆ|ƒ}ˆ |¡ nˆ ¡  ˆ ¡ }| ˆj	¡ ˆj
r„ˆjs¢xˆj ¡ D ]}| |¡ qW ˆ |¡ ˆj
r¶|rÒxˆ ¡ D ]}| |¡ qÀW |rú| ˆj¡ | ˆj¡ | ˆj¡ ˆjj ¡ s‡fdd„|D ƒ}t|tdƒd}ˆj‰ ˆ dk	r~|r~|d	 jˆ k r~| ¡  ‡ fd
d„|D ƒ}‡ fdd„|D ƒ}ng }ˆj
ržˆjržˆj	 |¡ |rÆx|D ]}	|	 |¡ qªW | ¡  t |ˆ|¡ | d¡ |ˆ_ dˆ_ dS )z*Draw everything (plot lines, axes, labels)NzNo renderer definedr.   Tc                s"   g | ]}|  ¡ r|ˆ jkr|‘qS r   )Zget_animatedr;  )r   r  )r1   r   r   r   (
  s    z"_AxesBase.draw.<locals>.<listcomp>Úzorder)rÐ   r   c                s   g | ]}|j ˆ k r|‘qS r   )rå  )r   r  )Úrasterization_zorderr   r   r   3
  s    c                s   g | ]}|j ˆ kr|‘qS r   )rå  )r   r  )ræ  r   r   r   5
  s    F)!r½   rt  rÖ   Z
open_grouprÓ   rÿ   r   rÝ  r–  r  rÕ   r·   r´   Úvaluesrä  rß  rC  rD  rE  ró   ÚcanvasZ	is_savingÚsortedr   r¹   rå  Zstart_rasterizingÚdrawZstop_rasterizingÚmimageZ_draw_list_compositing_imagesZclose_groupr
  )
r1   rã  Úinframer  r  r:  rL  Ú_axisZartists_rasterizedr  r   )ræ  r1   r   rê  ü	  s\    






z_AxesBase.drawc             C   s"   | j dkrtdƒ‚| | j ¡ dS )zÅ
        This method can only be used after an initial draw which
        caches the renderer.  It is used to efficiently update Axes
        data (axis ticks, labels, etc are not updated)
        NzLdraw_artist can only be used after an initial draw which caches the renderer)r½   rþ   rê  )r1   r  r   r   r   Údraw_artistJ
  s    
z_AxesBase.draw_artistc             C   s&   | j dkrtdƒ‚| j| j dd dS )zÅ
        This method can only be used after an initial draw which
        caches the renderer.  It is used to efficiently update Axes
        data (axis ticks, labels, etc are not updated)
        NzPredraw_in_frame can only be used after an initial draw which caches the rendererT)rì  )r½   rþ   rê  )r1   r   r   r   Úredraw_in_frameU
  s    
z_AxesBase.redraw_in_framec             C   s   | j S )N)r½   )r1   r   r   r   Úget_renderer_cache`
  s    z_AxesBase.get_renderer_cachec             C   s   | j S )z.Get whether the axes rectangle patch is drawn.)r·   )r1   r   r   r   Úget_frame_one
  s    z_AxesBase.get_frame_onc             C   s   || _ d| _dS )zx
        Set whether the axes rectangle patch is drawn.

        Parameters
        ----------
        b : bool
        TN)r·   r
  )r1   ry  r   r   r   Úset_frame_oni
  s    z_AxesBase.set_frame_onc             C   s   | j S )zÔ
        Get whether axis ticks and gridlines are above or below most artists.

        Returns
        -------
        axisbelow : bool or 'line'

        See Also
        --------
        set_axisbelow
        )Ú
_axisbelow)r1   r   r   r   Úget_axisbelowt
  s    z_AxesBase.get_axisbelowc             C   sf   t |ƒ | _}|dkrd}n$|dkr*d}n|dkr8d}ntdƒ‚x|  ¡ D ]}| |¡ qJW d| _dS )	aË  
        Set whether axis ticks and gridlines are above or below most artists.

        This controls the zorder of the ticks and gridlines. For more
        information on the zorder see :doc:`/gallery/misc/zorder_demo`.

        Parameters
        ----------
        b : bool or 'line'
            Possible values:

            - *True* (zorder = 0.5): Ticks and gridlines are below all Artists.
            - 'line' (zorder = 1.5): Ticks and gridlines are above patches (
              e.g. rectangles) but still below lines / markers.
            - *False* (zorder = 2.5): Ticks and gridlines are above patches
              and lines / markers.

        See Also
        --------
        get_axisbelow
        Tg      à?Fg      @rR   g      ø?zUnexpected axisbelow valueN)r   ró  r    rß  Z
set_zorderr
  )r1   ry  Z	axisbelowrå  r  r   r   r   r¸   ‚
  s    z_AxesBase.set_axisbelowrž   c             K   sr   t |ƒrd}n|dk	rt|ƒ}|dks.|dkrF| jj|fd|i|—Ž |dksV|dkrn| jj|fd|i|—Ž dS )ae  
        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.

        axis : {'both', 'x', 'y'}
            The axis to apply the changes on.

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

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

            Valid *kwargs* are

            %(Line2D)s

        Notes
        -----
        The grid will be drawn according to the axes' zorder and not its own.
        TNr]   r  r   r^   )r#   r	   rD   rë   rE   )r1   ry  r   r  r>   r   r   r   rë   ¥
  s    !z_AxesBase.grid)r  ÚstyleÚ	scilimitsÚ	useOffsetÚ	useLocaleÚuseMathTextc      
   	   C   sD  |  ¡ }|  ¡ }|dk	rRy|\}}|| d  W n  ttfk
rP   tdƒ‚Y nX |dd… dkrhd}	n$|dkrvd}	n|d	kr„d}	ntd
ƒ‚y’|	dk	rØ|dks¨|dkr¸| jjj |	¡ |dksÈ|dkrØ| jjj |	¡ |dk	r(|dksô|dkr| jjj |¡ |dks|dkr(| jjj |¡ |dk	rz|dksF|dkrV| jjj 	|¡ |dksj|dkrz| jjj 	|¡ |dk	rÌ|dks˜|dkr¨| jjj 
|¡ |dks¼|dkrÌ| jjj 
|¡ |dk	r|dksê|dkrú| jjj |¡ |dks|dkr| jjj |¡ W n tk
r>   tdƒ‚Y nX dS )a=  
        Change the `~matplotlib.ticker.ScalarFormatter` used by
        default for linear axes.

        Optional keyword arguments:

          ==============   =========================================
          Keyword          Description
          ==============   =========================================
          *axis*           [ 'x' | 'y' | 'both' ]
          *style*          [ 'sci' (or 'scientific') | 'plain' ]
                           plain turns off scientific notation
          *scilimits*      (m, n), pair of integers; if *style*
                           is 'sci', scientific notation will
                           be used for numbers outside the range
                           10\ :sup:`m` to 10\ :sup:`n`.
                           Use (0,0) to include all numbers.
                           Use (m,m) where m <> 0 to fix the order
                           of magnitude to 10\ :sup:`m`.
          *useOffset*      [ bool | offset ]; if True,
                           the offset will be calculated as needed;
                           if False, no offset will be used; if a
                           numeric offset is specified, it will be
                           used.
          *useLocale*      If True, format the number according to
                           the current locale.  This affects things
                           such as the character used for the
                           decimal separator.  If False, use
                           C-style (English) formatting.  The
                           default setting is controlled by the
                           axes.formatter.use_locale rcparam.
          *useMathText*    If True, render the offset and scientific
                           notation in mathtext
          ==============   =========================================

        Only the major ticks are affected.
        If the method is called when the
        :class:`~matplotlib.ticker.ScalarFormatter` is not the
        :class:`~matplotlib.ticker.Formatter` being used, an
        :exc:`AttributeError` will be raised.

        Nr   z*scilimits must be a sequence of 2 integersrv   ZsciTZplainFr   z%s is not a valid style valuer  r]   r^   z0This method only works with the ScalarFormatter.)r  r    r(  rD   rž   Z	formatterZset_scientificrE   Zset_powerlimitsZset_useOffsetZset_useLocaleZset_useMathTextrþ   )
r1   r  rõ  rö  r÷  rø  rù  rÀ  ÚnZsbr   r   r   Úticklabel_formatÐ
  sX    ,



z_AxesBase.ticklabel_formatc             K   sP   |dk}|dk}|r&| j  ¡ jf |Ž |r<| j ¡ jf |Ž | j|||d dS )a  
        Control behavior of tick locators.

        Parameters
        ----------
        axis : {'both', 'x', 'y'}, optional
            The axis on which to operate.

        tight : bool or None, optional
            Parameter passed to :meth:`autoscale_view`.
            Default is None, for no change.

        Other Parameters
        ----------------
        **kw :
            Remaining keyword arguments are passed to directly to the
            :meth:`~matplotlib.ticker.MaxNLocator.set_params` method.

        Typically one might want to reduce the maximum number
        of ticks and use tight bounds when plotting small
        subplots, for example::

            ax.locator_params(tight=True, nbins=4)

        Because the locator is involved in autoscaling,
        :meth:`autoscale_view` is called automatically after
        the parameters are changed.

        This presently works only for the
        :class:`~matplotlib.ticker.MaxNLocator` used
        by default on linear axes, but it may be generalized.
        )r]   r  )r^   r  )r|  r   r“   N)rD   rÔ  Z
set_paramsrE   r„  )r1   r  r|  r>   Z_xZ_yr   r   r   Úlocator_params*  s    !z_AxesBase.locator_paramsc             K   s    |dkrNt |ƒ}| dd¡ | dd¡ | dd¡ | dd¡ | jjf |Ž |dkrœt |ƒ}| dd¡ | d	d¡ | d
d¡ | dd¡ | jjf |Ž dS )aa	  Change the appearance of ticks, tick labels, and gridlines.

        Parameters
        ----------
        axis : {'x', 'y', 'both'}, optional
            Which axis to apply the parameters to.

        Other Parameters
        ----------------

        axis : {'x', 'y', 'both'}
            Axis on which to operate; default is 'both'.

        reset : bool
            If *True*, set all parameters to defaults
            before processing other keyword arguments.  Default is
            *False*.

        which : {'major', 'minor', 'both'}
            Default is 'major'; apply arguments to *which* ticks.

        direction : {'in', 'out', 'inout'}
            Puts ticks inside the axes, outside the axes, or both.

        length : float
            Tick length in points.

        width : float
            Tick width in points.

        color : color
            Tick color; accepts any mpl color spec.

        pad : float
            Distance in points between tick and label.

        labelsize : float or str
            Tick label font size in points or as a string (e.g., 'large').

        labelcolor : color
            Tick label color; mpl color spec.

        colors : color
            Changes the tick color and the label color to the same value:
            mpl color spec.

        zorder : float
            Tick and label zorder.

        bottom, top, left, right : bool
            Whether to draw the respective ticks.

        labelbottom, labeltop, labelleft, labelright : bool
            Whether to draw the respective tick labels.

        labelrotation : float
            Tick label rotation

        grid_color : color
            Changes the gridline color to the given mpl color spec.

        grid_alpha : float
            Transparency of gridlines: 0 (transparent) to 1 (opaque).

        grid_linewidth : float
            Width of gridlines in points.

        grid_linestyle : string
            Any valid :class:`~matplotlib.lines.Line2D` line style spec.

        Examples
        --------

        Usage ::

            ax.tick_params(direction='out', length=6, width=2, colors='r',
                           grid_color='r', grid_alpha=0.5)

        This will make all major ticks be red, pointing out of the box,
        and with dimensions 6 points by 2 points.  Tick labels will
        also be red.  Gridlines will be red and translucent.

        )r]   r  r™   Nrš   r›   rœ   )r^   r  r•   r–   r—   r˜   )ÚdictrF   rD   Zset_tick_paramsrE   )r1   r  r>   ZxkwZykwr   r   r   rÄ   S  s    Tz_AxesBase.tick_paramsc             C   s   d| _ d| _dS )z|
        Turn the x- and y-axis off.

        This affects the axis lines, ticks, ticklabels, grid and axis labels.
        FTN)rÕ   r
  )r1   r   r   r   r‚  ¶  s    z_AxesBase.set_axis_offc             C   s   d| _ d| _dS )z{
        Turn the x- and y-axis on.

        This affects the axis lines, ticks, ticklabels, grid and axis labels.
        TN)rÕ   r
  )r1   r   r   r   rI  ¿  s    z_AxesBase.set_axis_onc             C   s    | j |  ¡ ddd… dd dS )z˜
        Invert the x-axis.

        See Also
        --------
        xaxis_inverted
        get_xlim, set_xlim
        get_xbound, set_xbound
        Nru   )rŽ   )r"  r!  )r1   r   r   r   Úinvert_xaxisÊ  s    
z_AxesBase.invert_xaxisc             C   s   |   ¡ \}}||k S )zú
        Return whether the x-axis is inverted.

        The axis is inverted if the left value is larger than the right value.

        See Also
        --------
        invert_xaxis
        get_xlim, set_xlim
        get_xbound, set_xbound
        )r!  )r1   r™   rš   r   r   r   Úxaxis_invertedÖ  s    z_AxesBase.xaxis_invertedc             C   s(   |   ¡ \}}||k r||fS ||fS dS )zÆ
        Return the lower and upper x-axis bounds, in increasing order.

        See Also
        --------
        set_xbound
        get_xlim, set_xlim
        invert_xaxis, xaxis_inverted
        N)r!  )r1   r™   rš   r   r   r   ra  å  s    
z_AxesBase.get_xboundc             C   sž   |dkrt |ƒr|\}}|  ¡ \}}|dkr0|}|dkr<|}|  ¡ rp||k r^| j||dd qš| j||dd n*||k rŠ| j||dd n| j||dd dS )a  
        Set the lower and upper numerical bounds of the x-axis.

        This method will honor axes inversion regardless of parameter order.
        It will not change the autoscaling setting (``Axes._autoscaleXon``).

        Parameters
        ----------
        lower, upper : float or None
            The lower and upper bounds. If *None*, the respective axis bound
            is not modified.

        See Also
        --------
        get_xbound
        get_xlim, set_xlim
        invert_xaxis, xaxis_inverted
        N)rŽ   )r
   ra  rÿ  r"  )r1   r  ÚupperÚ	old_lowerÚ	old_upperr   r   r   rv  õ  s    z_AxesBase.set_xboundc             C   s   t | jjƒS )aº  
        Return the x-axis view limits.

        Returns
        -------
        left, right : (float, float)
            The current x-axis limits in data coordinates.

        See Also
        --------
        set_xlim
        set_xbound, get_xbound
        invert_xaxis, xaxis_inverted

        Notes
        -----
        The x-axis may be inverted, in which case the *left* value will
        be greater than the *right* value.

        )Útuplerá   rÏ  )r1   r   r   r   r!    s    z_AxesBase.get_xlimc             C   s4   |dk	r0||ƒ}t |tƒr,t |¡s,tdƒ‚|S dS )zû
        Raise ValueError if converted limits are non-finite.

        Note that this function also accepts None as a limit argument.

        Returns
        -------
        The limit value after call to convert(), or None if limit is None.

        Nz Axis limits cannot be NaN or Inf)rx   r   r\   rÍ  r    )r1   ÚlimitZconvertZconverted_limitr   r   r   Ú_validate_converted_limits4  s    

z$_AxesBase._validate_converted_limits)rd  re  c      
      C   sî  |dkrt |ƒr|\}}|dk	rFtjddddd |dk	rBtdƒ‚|}|dk	rttjddd	dd |dk	rptd
ƒ‚|}| j||fd |  || j¡}|  || j¡}|  ¡ \}}|dkr¸|}|dkrÄ|}||krâtj	d||f dd t
j||dd\}}|  ¡ dkr<|dkr tj	ddd |}|dkr<tj	ddd |}| j ||¡\}}||f| j_|dk	rnt|ƒ| _|rà| j d| ¡ x\| j | ¡D ]L}	|	| k	r|	j| jjd|d |	j| jkr|	jjdk	r|	jj ¡  qW d| _||fS )ac  
        Set the x-axis view limits.

        .. ACCEPTS: (left: float, right: float)

        Parameters
        ----------
        left : scalar, optional
            The left xlim in data coordinates. Passing *None* leaves the
            limit unchanged.

            The left and right xlims may be passed as the tuple
            (`left`, `right`) as the first positional argument (or as
            the `left` keyword argument).

        right : scalar, optional
            The right xlim in data coordinates. Passing *None* leaves the
            limit unchanged.

        emit : bool, optional
            Whether to notify observers of limit change (default: True).

        auto : bool or None, optional
            Whether to turn on autoscaling of the x-axis. True turns on,
            False turns off (default action), None leaves unchanged.

        xmin, xmax : scalar, optional
            These arguments are deprecated and will be removed in a future
            version.  They are equivalent to left and right respectively,
            and it is an error to pass both *xmin* and *left* or
            *xmax* and *right*.

        Returns
        -------
        left, right : (float, float)
            The new x-axis limits in data coordinates.

        See Also
        --------
        get_xlim
        set_xbound, get_xbound
        invert_xaxis, xaxis_inverted

        Notes
        -----
        The *left* value may be greater than the *right* value, in which
        case the x-axis values will decrease from left to right.

        Examples
        --------
        >>> set_xlim(left, right)
        >>> set_xlim((left, right))
        >>> left, right = set_xlim(left, right)

        One limit may be left unchanged.

        >>> set_xlim(right=right_lim)

        Limits may be passed in reverse order to flip the direction of
        the x-axis. For example, suppose ``x`` represents the number of
        years before present. The x-axis limits might be set like the
        following so 5000 years ago is on the left of the plot and the
        present is on the right.

        >>> set_xlim(5000, 0)

        Nz3.0z`xmin`z`left`Úargument)rH   Úalternativer^  z"Cannot pass both `xmin` and `left`z`xmax`z`right`z#Cannot pass both `xmax` and `right`)rµ  zwAttempting to set identical left==right results
in singular transformations; automatically expanding.
left=%s, right=%srV   )ro  F)rÒ  rn  r   z\Attempted to set non-positive left xlim on a log-scaled axis.
Invalid limit will be ignored.z]Attempted to set non-positive right xlim on a log-scaled axis.
Invalid limit will be ignored.Zxlim_changed)r  rŽ   T)r
   r   rz   r(  r·  r  rX   r!  rr  rs  r¡   rÕ  rp  rD   rØ  rá   rÏ  r¿  r/  rÃ   Úprocessr­   rÏ   r"  ró   rè  Ú	draw_idler
  )
r1   r™   rš   r  rŽ   rd  re  Zold_leftZ	old_rightÚotherr   r   r   r"  F  sj    E








z_AxesBase.set_xlimc             C   s
   | j  ¡ S )zj
        Return the x-axis scale as string.

        See Also
        --------
        set_xscale
        )rD   r%  )r1   r   r   r   rp  Ì  s    z_AxesBase.get_xscalec             K   sJ   |   ¡ }x0| | ¡D ]"}|jj|f|Ž | ¡  d|_qW | jdd dS )aý  
        Set the x-axis scale.

        Parameters
        ----------
        value : {"linear", "log", "symlog", "logit", ...}
            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`


        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.
        TF)r“   N)Úget_shared_x_axesrÏ   rD   r'  rÝ   r
  r„  )r1   r‰   r>   Úgr  r   r   r   rÀ   Ö  s    
z_AxesBase.set_xscalec             C   s   | j j|dS )z)Return the x ticks as a list of locations)r”   )rD   Úget_ticklocs)r1   r”   r   r   r   Ú
get_xticksø  s    z_AxesBase.get_xticksc             C   s   | j j||d}d| _|S )a(  
        Set the x ticks with list of *ticks*

        Parameters
        ----------
        ticks : list
            List of x-axis tick locations.

        minor : bool, optional
            If ``False`` sets major ticks, if ``True`` sets minor ticks.
            Default is ``False``.
        )r”   T)rD   Ú	set_ticksr
  )r1   Úticksr”   rK   r   r   r   Ú
set_xticksü  s    z_AxesBase.set_xticksc             C   s   t  d| j ¡ ¡S )z¢
        Get the major x tick labels.

        Returns
        -------
        labels : list
            List of :class:`~matplotlib.text.Text` instances
        zText xticklabel)r   rˆ  rD   Úget_majorticklabels)r1   r   r   r   Úget_xmajorticklabels  s    	z_AxesBase.get_xmajorticklabelsc             C   s   t  d| j ¡ ¡S )z¢
        Get the minor x tick labels.

        Returns
        -------
        labels : list
            List of :class:`~matplotlib.text.Text` instances
        zText xticklabel)r   rˆ  rD   Úget_minorticklabels)r1   r   r   r   Úget_xminorticklabels  s    	z_AxesBase.get_xminorticklabelsc             C   s   t  d| jj||d¡S )aù  
        Get the x tick labels as a list of :class:`~matplotlib.text.Text`
        instances.

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

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

           Selects which ticklabels to return

        Returns
        -------
        ret : list
           List of :class:`~matplotlib.text.Text` instances.
        zText xticklabel)r”   r   )r   rˆ  rD   Úget_ticklabels)r1   r”   r   r   r   r   Úget_xticklabels%  s    z_AxesBase.get_xticklabelsc             K   s4   |dk	r|  |¡ | jj|fd|i|—Ž}d| _|S )a%  
        Set the x-tick labels with list of string labels.

        Parameters
        ----------
        labels : List[str]
            List of string labels.

        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, optional
            Whether to set the minor ticklabels rather than the major ones.

        Returns
        -------
        A list of `~.text.Text` instances.

        Other Parameters
        -----------------
        **kwargs : `~.text.Text` properties.
        Nr”   T)rÂ   rD   Úset_ticklabelsr
  )r1   ÚlabelsÚfontdictr”   r>   rK   r   r   r   Úset_xticklabels>  s    
z_AxesBase.set_xticklabelsc             C   s    | j |  ¡ ddd… dd dS )z˜
        Invert the y-axis.

        See Also
        --------
        yaxis_inverted
        get_ylim, set_ylim
        get_ybound, set_ybound
        Nru   )rŽ   )r*  r)  )r1   r   r   r   Úinvert_yaxisb  s    
z_AxesBase.invert_yaxisc             C   s   |   ¡ \}}||k S )zú
        Return whether the y-axis is inverted.

        The axis is inverted if the bottom value is larger than the top value.

        See Also
        --------
        invert_yaxis
        get_ylim, set_ylim
        get_ybound, set_ybound
        )r)  )r1   r–   r•   r   r   r   Úyaxis_invertedn  s    z_AxesBase.yaxis_invertedc             C   s(   |   ¡ \}}||k r||fS ||fS dS )zÆ
        Return the lower and upper y-axis bounds, in increasing order.

        See Also
        --------
        set_ybound
        get_ylim, set_ylim
        invert_yaxis, yaxis_inverted
        N)r)  )r1   r–   r•   r   r   r   rb  }  s    
z_AxesBase.get_yboundc             C   sž   |dkrt |ƒr|\}}|  ¡ \}}|dkr0|}|dkr<|}|  ¡ rp||k r^| j||dd qš| j||dd n*||k rŠ| j||dd n| j||dd dS )a  
        Set the lower and upper numerical bounds of the y-axis.

        This method will honor axes inversion regardless of parameter order.
        It will not change the autoscaling setting (``Axes._autoscaleYon``).

        Parameters
        ----------
        lower, upper : float or None
            The lower and upper bounds. If *None*, the respective axis bound
            is not modified.

        See Also
        --------
        get_ybound
        get_ylim, set_ylim
        invert_yaxis, yaxis_inverted
        N)rŽ   )r
   rb  r  r*  )r1   r  r   r  r  r   r   r   ru    s    z_AxesBase.set_yboundc             C   s   t | jjƒS )aº  
        Return the y-axis view limits.

        Returns
        -------
        bottom, top : (float, float)
            The current y-axis limits in data coordinates.

        See Also
        --------
        set_ylim
        set_ybound, get_ybound
        invert_yaxis, yaxis_inverted

        Notes
        -----
        The y-axis may be inverted, in which case the *bottom* value
        will be greater than the *top* value.

        )r  rá   rÑ  )r1   r   r   r   r)  µ  s    z_AxesBase.get_ylim)rf  rg  c      
      C   sî  |dkrt |ƒr|\}}|dk	rFtjddddd |dk	rBtdƒ‚|}|dk	rttjddd	dd |dk	rptd
ƒ‚|}| j||fd |  || j¡}|  || j¡}|  ¡ \}}|dkr¸|}|dkrÄ|}||krâtj	d||f dd t
j||dd\}}|  ¡ dkr<|dkr tj	ddd |}|dkr<tj	ddd |}| j ||¡\}}||f| j_|dk	rnt|ƒ| _|rà| j d| ¡ x\| j | ¡D ]L}	|	| k	r|	j| jjd|d |	j| jkr|	jjdk	r|	jj ¡  qW d| _||fS )ac  
        Set the y-axis view limits.

        .. ACCEPTS: (bottom: float, top: float)

        Parameters
        ----------
        bottom : scalar, optional
            The bottom ylim in data coordinates. Passing *None* leaves the
            limit unchanged.

            The bottom and top ylims may be passed as the tuple
            (`bottom`, `top`) as the first positional argument (or as
            the `bottom` keyword argument).

        top : scalar, optional
            The top ylim in data coordinates. Passing *None* leaves the
            limit unchanged.

        emit : bool, optional
            Whether to notify observers of limit change (default: True).

        auto : bool or None, optional
            Whether to turn on autoscaling of the y-axis. *True* turns on,
            *False* turns off (default action), *None* leaves unchanged.

        ymin, ymax : scalar, optional
            These arguments are deprecated and will be removed in a future
            version.  They are equivalent to bottom and top respectively,
            and it is an error to pass both *ymin* and *bottom* or
            *ymax* and *top*.

        Returns
        -------
        bottom, top : (float, float)
            The new y-axis limits in data coordinates.

        See Also
        --------
        get_ylim
        set_ybound, get_ybound
        invert_yaxis, yaxis_inverted

        Notes
        -----
        The *bottom* value may be greater than the *top* value, in which
        case the y-axis values will decrease from *bottom* to *top*.

        Examples
        --------
        >>> set_ylim(bottom, top)
        >>> set_ylim((bottom, top))
        >>> bottom, top = set_ylim(bottom, top)

        One limit may be left unchanged.

        >>> set_ylim(top=top_lim)

        Limits may be passed in reverse order to flip the direction of
        the y-axis. For example, suppose ``y`` represents depth of the
        ocean in m. The y-axis limits might be set like the following
        so 5000 m depth is at the bottom of the plot and the surface,
        0 m, is at the top.

        >>> set_ylim(5000, 0)
        Nz3.0z`ymin`z`bottom`r  )rH   r  r^  z$Cannot pass both `ymin` and `bottom`z`ymax`z`top`z!Cannot pass both `ymax` and `top`)r¶  zwAttempting to set identical bottom==top results
in singular transformations; automatically expanding.
bottom=%s, top=%srV   )ro  F)rÒ  rn  r   z^Attempted to set non-positive bottom ylim on a log-scaled axis.
Invalid limit will be ignored.z[Attempted to set non-positive top ylim on a log-scaled axis.
Invalid limit will be ignored.Zylim_changed)r  rŽ   T)r
   r   rz   r(  r·  r  rY   r)  rr  rs  r¡   rÕ  rq  rE   rØ  rá   rÑ  r¿  r0  rÃ   r  r¯   rÏ   r*  ró   rè  r	  r
  )
r1   r–   r•   r  rŽ   rf  rg  Z
old_bottomZold_topr
  r   r   r   r*  Ì  sj    D








z_AxesBase.set_ylimc             C   s
   | j  ¡ S )zj
        Return the x-axis scale as string.

        See Also
        --------
        set_yscale
        )rE   r%  )r1   r   r   r   rq  R  s    z_AxesBase.get_yscalec             K   sJ   |   ¡ }x0| | ¡D ]"}|jj|f|Ž | ¡  d|_qW | jdd dS )aý  
        Set the y-axis scale.

        Parameters
        ----------
        value : {"linear", "log", "symlog", "logit", ...}
            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`


        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.
        TF)r   N)Úget_shared_y_axesrÏ   rE   r'  rÝ   r
  r„  )r1   r‰   r>   r  r  r   r   r   rÁ   \  s    
z_AxesBase.set_yscalec             C   s   | j j|dS )z)Return the y ticks as a list of locations)r”   )rE   r  )r1   r”   r   r   r   Ú
get_yticks}  s    z_AxesBase.get_yticksc             C   s   | j j||d}|S )a'  
        Set the y ticks with list of *ticks*

        Parameters
        ----------
        ticks : list
            List of y-axis tick locations

        minor : bool, optional
            If ``False`` sets major ticks, if ``True`` sets minor ticks.
            Default is ``False``.
        )r”   )rE   r  )r1   r  r”   rK   r   r   r   Ú
set_yticks  s    z_AxesBase.set_yticksc             C   s   t  d| j ¡ ¡S )z¢
        Get the major y tick labels.

        Returns
        -------
        labels : list
            List of :class:`~matplotlib.text.Text` instances
        zText yticklabel)r   rˆ  rE   r  )r1   r   r   r   Úget_ymajorticklabels‘  s    	z_AxesBase.get_ymajorticklabelsc             C   s   t  d| j ¡ ¡S )z¢
        Get the minor y tick labels.

        Returns
        -------
        labels : list
            List of :class:`~matplotlib.text.Text` instances
        zText yticklabel)r   rˆ  rE   r  )r1   r   r   r   Úget_yminorticklabels  s    	z_AxesBase.get_yminorticklabelsc             C   s   t  d| jj||d¡S )aî  
        Get the y tick labels as a list of :class:`~matplotlib.text.Text`
        instances.

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

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

           Selects which ticklabels to return

        Returns
        -------
        ret : list
           List of :class:`~matplotlib.text.Text` instances.
        zText yticklabel)r”   r   )r   rˆ  rE   r  )r1   r”   r   r   r   r   Úget_yticklabels©  s    z_AxesBase.get_yticklabelsc             K   s*   |dk	r|  |¡ | jj|fd|i|—ŽS )a$  
        Set the y-tick labels with list of strings labels.

        Parameters
        ----------
        labels : List[str]
            list of string labels

        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, optional
            Whether to set the minor ticklabels rather than the major ones.

        Returns
        -------
        A list of `~.text.Text` instances.

        Other Parameters
        ----------------
        **kwargs : `~.text.Text` properties.
        Nr”   )rÂ   rE   r  )r1   r  r  r”   r>   r   r   r   Úset_yticklabelsÂ  s    
z_AxesBase.set_yticklabelsc             C   s   | j  |¡ dS )zñ
        Sets up x-axis ticks and labels that treat the x data as dates.

        Parameters
        ----------
        tz : string or :class:`tzinfo` instance, optional
            Timezone string or timezone. Defaults to rc value.
        N)rD   Ú	axis_date)r1   Útzr   r   r   Ú
xaxis_dateä  s    z_AxesBase.xaxis_datec             C   s   | j  |¡ dS )zñ
        Sets up y-axis ticks and labels that treat the y data as dates.

        Parameters
        ----------
        tz : string or :class:`tzinfo` instance, optional
            Timezone string or timezone. Defaults to rc value.
        N)rE   r%  )r1   r&  r   r   r   Ú
yaxis_dateñ  s    	z_AxesBase.yaxis_datec             C   s8   y
|   |¡S  tk
r2   | j ¡ j}||ƒ}|S X dS )z·
        Return *x* string formatted.  This function will use the attribute
        self.fmt_xdata if it is callable, else will fall back on the xaxis
        major formatter
        N)r»   r(  rD   Úget_major_formatterÚformat_data_short)r1   r]   r   Úvalr   r   r   Úformat_xdataü  s    
z_AxesBase.format_xdatac             C   s8   y
|   |¡S  tk
r2   | j ¡ j}||ƒ}|S X dS )z¸
        Return y string formatted.  This function will use the
        :attr:`fmt_ydata` attribute if it is callable, else will fall
        back on the yaxis major formatter
        N)r¼   r(  rE   r)  r*  )r1   r^   r   r+  r   r   r   Úformat_ydata	  s    
z_AxesBase.format_ydatac             C   s<   |dkrd}n
|   |¡}|dkr&d}n
|  |¡}d||f S )z4Return a format string formatting the *x*, *y* coordNz???z	x=%s y=%s)r,  r-  )r1   r]   r^   rË  rÌ  r   r   r   Úformat_coord  s    

z_AxesBase.format_coordc             C   s|   xv| j | jfD ]f}| ¡ }|dkr@|j}| t |j|j¡¡ q|dkrf|j}| t 	|j
|j¡¡ q| t ¡ ¡ qW dS )zÀ
        Display minor ticks on the axes.

        Displaying minor ticks may reduce performance; you may turn them off
        using `minorticks_off()` if drawing speed is a problem.
        rn  ZsymlogN)rD   rE   r%  r&  r,  r-  Z
LogLocatorÚbaseZsubsZSymmetricalLogLocatorZ
_transformr.  )r1   r  rÙ  r†  r   r   r   Úminorticks_on"  s    z_AxesBase.minorticks_onc             C   s$   | j  t ¡ ¡ | j t ¡ ¡ dS )z!Remove minor ticks from the axes.N)rD   r,  r-  ZNullLocatorrE   )r1   r   r   r   Úminorticks_off5  s    z_AxesBase.minorticks_offc             C   s   dS )zX
        Return *True* if this axes supports the zoom box button functionality.
        Tr   )r1   r   r   r   Úcan_zoom<  s    z_AxesBase.can_zoomc             C   s   dS )zX
        Return *True* if this axes supports any pan/zoom button functionality.
        Tr   )r1   r   r   r   Úcan_panB  s    z_AxesBase.can_panc             C   s   | j S )zF
        Get whether the axes responds to navigation commands
        )Ú	_navigate)r1   r   r   r   Úget_navigateH  s    z_AxesBase.get_navigatec             C   s
   || _ dS )z†
        Set whether the axes responds to navigation toolbar commands

        Parameters
        ----------
        b : bool
        N)r4  )r1   ry  r   r   r   r¾   N  s    z_AxesBase.set_navigatec             C   s   | j S )zR
        Get the navigation toolbar button status: 'PAN', 'ZOOM', or None
        )Ú_navigate_mode)r1   r   r   r   Úget_navigate_modeX  s    z_AxesBase.get_navigate_modec             C   s
   || _ dS )z
        Set the navigation toolbar button status;

        .. warning::
            this is not a user-API function.

        N)r6  )r1   ry  r   r   r   r¿   ^  s    z_AxesBase.set_navigate_modec             C   s$   |   ¡ \}}|  ¡ \}}||||fS )aî  
        Save information required to reproduce the current view.

        Called before a view is changed, such as during a pan or zoom
        initiated by the user. You may return any information you deem
        necessary to describe the view.

        .. note::

            Intended to be overridden by new projection types, but if not, the
            default implementation saves the view limits. You *must* implement
            :meth:`_set_view` if you implement this method.
        )r!  r)  )r1   rd  re  rf  rg  r   r   r   Ú	_get_viewh  s    z_AxesBase._get_viewc             C   s,   |\}}}}|   ||f¡ |  ||f¡ dS )am  
        Apply a previously saved view.

        Called when restoring a view, such as with the navigation buttons.

        .. note::

            Intended to be overridden by new projection types, but if not, the
            default implementation restores the view limits. You *must*
            implement :meth:`_get_view` if you implement this method.
        N)r"  r*  )r1   Zviewrd  re  rf  rg  r   r   r   Ú	_set_viewz  s    z_AxesBase._set_viewÚinc       &      C   sN  |   ¡ \}}|  ¡ \}}	t|ƒdkr|\}
}}|dkr<d}|dkrJd}nd}d| }| jj}|||fƒ\}}|||	fƒ\}}|| }|| }|| d }|| d }|
|d  | | }||d  | | }||d |  ||d |  ||d |  ||d |  g}n t|ƒd	kr,tjd
dd dS |\}}}}| j ¡ }| ||f¡\}}| ||f¡\}}|rx|| }}n„||k rÀ||k r˜|| }}n
|| }}||k r°|}||krü|}n<||krÖ|| }}n
|| }}||krî|}||k rü|}|r||	 }} n„||	k rV||k r.|| }} n
|| }} ||k rF|}| |	kr’|	} n<||krl|| }} n
|| }} ||kr„|}| |	k r’|	} |dkrð|dkr¶|  	||f¡ n6|dkrÐ|  
|| f¡ n|  	||f¡ |  
|| f¡ nZ|dkrJ|  ¡ dkrJt || ¡t || ¡ }!t|| |!ƒ| }"t|| |!ƒ| }#n0|| ||  }!|!||  | }"|!||  | }#|  ¡ dkrÊt |	| ¡t | | ¡ }!t|| |!ƒ| }$t|	| |!ƒ| }%n0|	| | |  }!|!||  | }$|!|	|  | }%|dkr|  	|"|#f¡ n6|dkr.|  
|$|%f¡ n|  	|"|#f¡ |  
|$|%f¡ dS )a÷  
        Update view from a selection bbox.

        .. note::

            Intended to be overridden by new projection types, but if not, the
            default implementation sets the view limits to the bbox directly.

        Parameters
        ----------

        bbox : 4-tuple or 3 tuple
            * If bbox is a 4 tuple, it is the selected bounding box limits,
                in *display* coordinates.
            * If bbox is a 3 tuple, it is an (xp, yp, scl) triple, where
                (xp,yp) is the center of zooming and scl the scale factor to
                zoom by.

        direction : str
            The direction to apply the bounding box.
                * `'in'` - The bounding box describes the view directly, i.e.,
                           it zooms in.
                * `'out'` - The bounding box describes the size to make the
                            existing view, i.e., it zooms out.

        mode : str or None
            The selection mode, whether to apply the bounding box in only the
            `'x'` direction, `'y'` direction or both (`None`).

        twinx : bool
            Whether this axis is twinned in the *x*-direction.

        twiny : bool
            Whether this axis is twinned in the *y*-direction.
        rv   r   g      ð?r   r:  Úoutg      à?g       @r€  zgWarning in _set_view_from_bbox: bounding box is not a tuple of length 3 or 4. Ignoring the view change.rV   )ro  Nr]   r^   rn  )r!  r)  r#   rç   r«  rr  rs  rÖ  Ztransform_pointr"  r*  rp  r\   rn  Úpowrq  )&r1   rÔ   Ú	directionÚmodeÚtwinxÚtwinyZXminZXmaxZYminZYmaxZxpZypZsclZtranD2Crd  rf  re  rg  ZxwidthZywidthZxcenZycenZxzcZyzcZlastxZlastyr]   r^   Zinverser×   rÙ   rØ   rÚ   ÚalphaZrx1Zrx2Zry1Zry2r   r   r   Ú_set_view_from_bboxŠ  s¸    %
"
























z_AxesBase._set_view_from_bboxc             C   s8   t j| j ¡ | j ¡ | j ¡  ¡ | j ¡ ||d| _dS )a2  
        Called when a pan operation has started.

        *x*, *y* are the mouse coordinates in display coords.
        button is the mouse button number:

        * 1: LEFT
        * 2: MIDDLE
        * 3: RIGHT

        .. note::

            Intended to be overridden by new projection types.

        )ÚlimÚtransÚtrans_inverserÔ   r]   r^   N)ÚtypesÚSimpleNamespacerá   r¦   rç   rÖ  rÔ   Ú
_pan_start)r1   r]   r^   Úbuttonr   r   r   Ú	start_pan-  s    z_AxesBase.start_panc             C   s   | ` dS )z²
        Called when a pan operation completes (when the mouse button
        is up.)

        .. note::

            Intended to be overridden by new projection types.

        N)rH  )r1   r   r   r   Úend_panE  s    
z_AxesBase.end_panc             C   s   dd„ }| j }||j }||j }||  kr6dkr>n ndS |dkrr||||ƒ\}}|j | | ¡ |j¡}	nÔ|dkrByž| | jj }| | jj }||||ƒ\}}|  	¡ dkrÆd||   }}t
 d	||f¡}
t
 |j|jg¡}|j |j¡}||
||   }t |¡ |j¡}	W n$ tk
r>   tjd
dd dS X ndS t
 |	 |j¡¡}|	 ¡  t¡}d|| < |  |dd…df ¡ |  |dd…df ¡ dS )a`  
        Called when the mouse moves during a pan operation.

        *button* is the mouse button number:

        * 1: LEFT
        * 2: MIDDLE
        * 3: RIGHT

        *key* is a "shift" key

        *x*, *y* are the mouse coordinates in display coords.

        .. note::

            Intended to be overridden by new projection types.

        c             S   s¾   | dkr$t |ƒt |ƒkr|}q¶|}n’| dkr2d}n„| dkr@d}nv| dkr¶dt |ƒ t |ƒk rbd}nTdt |ƒ t |ƒk r|d}n:t |ƒt |ƒkr¢|t |ƒ t |ƒ }n|t |ƒ t |ƒ }||fS )NZcontrolr]   r   r^   ÚshiftrV   )rc  )rÐ   ÚdxÚdyr   r   r   Úformat_deltasd  s"    z)_AxesBase.drag_pan.<locals>.format_deltasr   Nr   rv   rŽ   g      à?g      $@zOverflow while panningrV   )ro  )rH  r]   r^   rÔ   Z
translatedZtransformedrE  r¤   r¥   rS  r\   ZpowerZarrayrC  rD  r¡   r¢   ÚOverflowErrorrr  rs  rÍ  r°  ZastypeÚobjectr"  r*  )r1   rI  rÐ   r]   r^   rO  rg   rM  rN  ÚresultrA  ÚstartZ	oldpointsZ	newpointsZvalidZpointsr   r   r   Údrag_panQ  s>    




z_AxesBase.drag_panc             C   sÖ   g }|  | j¡ |  | j¡ |  | j¡ |  | j¡ |  | j¡ |  | j ¡ ¡ | | j	¡ | | j
¡ | | j¡ | | j¡ | | j¡ |  | j¡ |  | j¡ |  | j¡ | jdk	rÆ| | j¡ | | j¡ |S )zreturn a list of child artistsN)rÓ  r?  r7  rü   r8  r:  r´   rç  r}   rD   rE   rC  rD  rE  r9  r;  r<  r>  r  )r1   Zchildrenr   r   r   rÝ  ›  s&    
z_AxesBase.get_childrenc             C   s"   t | jƒr|  | |¡S | j |¡S )zj
        Test whether the mouse event occurred in the axes.

        Returns *True* / *False*, {}
        )ÚcallableZ	_containsr  r¸  )r1   r¹  r   r   r   r¸  ³  s    
z_AxesBase.containsc             C   s   | j j|ddS )z¥
        Returns *True* if the point (tuple of x,y) is inside the axes
        (the area defined by the its patch). A pixel coordinate is
        required.

        g      ð?)Zradius)r  Úcontains_point)r1   Zpointr   r   r   rV  ½  s    z_AxesBase.contains_pointc             G   s   t j | |d ¡ dS )zÌTrigger pick event

        Call signature::

            pick(mouseevent)

        each child artist will fire a pick event if mouseevent is over
        the artist and the artist has picker set
        r   N)rŸ   r    Úpick)r1   r=   r   r   r   rW  Æ  s    
z_AxesBase.pickc             C   sb   |   ¡ }| jr| js2x| j ¡ D ]}| |¡ q W | jsTx|  ¡ D ]}| |¡ qBW dd„ |D ƒS )zÐ
        Return a default list of artists that are used for the bounding box
        calculation.

        Artists are excluded either by not being visible or
        ``artist.set_in_layout(False)``.
        c             S   s    g | ]}|  ¡ r| ¡ r|‘qS r   )rÖ   Zget_in_layout)r   rÉ  r   r   r   r   å  s    z<_AxesBase.get_default_bbox_extra_artists.<locals>.<listcomp>)rÝ  rÕ   r·   r´   rç  r–  rß  )r1   r:  rL  rí  r   r   r   Úget_default_bbox_extra_artistsÒ  s    	z(_AxesBase.get_default_bbox_extra_artistsc             C   sf  g }|   ¡ sdS |  ¡ }|r6|r6|| |ƒ}|  |¡ n|  ¡  | j |¡}|rX| |¡ |  |¡ | |  |¡¡ | j  ¡ rŽ| | j |¡¡ | j	  ¡ rª| | j	 |¡¡ | j
  ¡ rÆ| | j
 |¡¡ | j |¡}|rà| |¡ |}	|	dkrô|  ¡ }	xV|	D ]N}
|
 |¡}|dk	rú|jdks&|jdkrút |j¡rút |j¡rú| |¡ qúW tj dd„ |D ƒ¡}|S )a”  
        Return the tight bounding box of the axes, including axis and their
        decorators (xlabel, title, etc).

        Artists that have ``artist.set_in_layout(False)`` are not included
        in the bbox.

        Parameters
        ----------
        renderer : `.RendererBase` instance
            renderer that will be used to draw the figures (i.e.
            ``fig.canvas.get_renderer()``)

        bbox_extra_artists : list of `.Artist` or ``None``
            List of artists to include in the tight bounding box.  If
            ``None`` (default), then all artist children of the axes are
            included in the tight bounding box.

        call_axes_locator : boolean (default ``True``)
            If *call_axes_locator* is ``False``, it does not call the
            ``_axes_locator`` attribute, which is necessary to get the correct
            bounding box. ``call_axes_locator=False`` can be used if the
            caller is only interested in the relative size of the tightbbox
            compared to the axes bbox.

        Returns
        -------
        bbox : `.BboxBase`
            bounding box in figure pixel coordinates.
        Nr   c             S   s$   g | ]}|j d ks|jd kr|‘qS )r   )r¤   r¥   )r   ry  r   r   r   r   3  s    z+_AxesBase.get_tightbbox.<locals>.<listcomp>)rÖ   rÿ   r   rD   râ  r}   rä  rÛ   rC  rD  rE  rE   rX  r¤   r¥   r\   rÍ  r¡   r¢   r±  )r1   rã  Zcall_axes_locatorZbbox_extra_artistsrÛ  r  r  Zbb_xaxisZbb_yaxisZbbox_artistsr  rÔ   Z_bboxr   r   r   râ  è  sD    !








z_AxesBase.get_tightbboxc             O   sX   d|krd|krt dƒ‚| jj|  d¡f|ž|Ž}|  d¡ | d¡ | j | |¡ |S )zN
        Make a twinx axes of self. This is used for twinx and twiny.
        rÈ   rÉ   z%Twinned Axes may share only one axis.Tr_  )r    ró   Zadd_axesr  rW  rÌ   r®   )r1   Zklr>   Úax2r   r   r   Ú_make_twin_axes7  s    

z_AxesBase._make_twin_axesc             C   sb   | j | d}|j ¡  |j d¡ |j d¡ | |  ¡ ¡ | j ¡  |j 	d¡ |j
 	d¡ |S )a’  
        Create a twin Axes sharing the xaxis

        Create a new Axes instance with an invisible x-axis and an independent
        y-axis positioned opposite to the original one (i.e. at right). The
        x-axis autoscale setting will be inherited from the original Axes.
        To ensure that the tick marks of both y-axes align, see
        `~matplotlib.ticker.LinearLocator`

        Returns
        -------
        ax_twin : Axes
            The newly created Axes instance

        Notes
        -----
        For those who are 'picking' artists while using twinx, pick
        events are only called for the artists in the top-most axes.
        )rÈ   rš   F)rZ  rE   Z
tick_rightÚset_label_positionZset_offset_positionr¼  r#  Z	tick_leftrD   rK  r  )r1   rY  r   r   r   r?  E  s    

z_AxesBase.twinxc             C   sV   | j | d}|j ¡  |j d¡ | |  ¡ ¡ | j ¡  |j d¡ |j	 d¡ |S )a  
        Create a twin Axes sharing the yaxis

        Create a new Axes instance with an invisible y-axis and an independent
        x-axis positioned opposite to the original one (i.e. at top). The
        y-axis autoscale setting will be inherited from the original Axes.
        To ensure that the tick marks of both x-axes align, see
        `~matplotlib.ticker.LinearLocator`

        Returns
        -------
        ax_twin : Axes
            The newly created Axes instance

        Notes
        -----
        For those who are 'picking' artists while using twiny, pick
        events are only called for the artists in the top-most axes.
        )rÉ   r•   F)
rZ  rD   Ztick_topr[  r½  r+  Ztick_bottomrE   rK  r  )r1   rY  r   r   r   r@  c  s    

z_AxesBase.twinyc             C   s   | j S )z@Return a reference to the shared axes Grouper object for x axes.)r­   )r1   r   r   r   r    s    z_AxesBase.get_shared_x_axesc             C   s   | j S )z@Return a reference to the shared axes Grouper object for y axes.)r¯   )r1   r   r   r   r  …  s    z_AxesBase.get_shared_y_axes)NTNNr   NN)rë   )rë   )F)r  )r  )Nr  r  )NNF)F)F)N)T)FF)F)TT)NNN)Tr  N)NTT)NF)Nrž   r  )r  N)r  )NN)NNTF)F)F)FN)NF)NN)NNTF)F)F)FN)NF)N)N)r:  NFF)TN)´rƒ   r„   r…   r†   rH   r   ZGrouperr­   r¯   rÌ   Úpropertyrˆ   Úsetterr   r2   r3   r7   rÛ   rµ   r±   rå   rï   r÷   rø   rù   rú   rû   rÝ   r  r  r  r  r²   rÿ   r  r  r³   rº   Z
deprecatedrP  rQ  rR  Zget_fcrH  Zset_fcrF  r0   rS  r\  r]  rW  r`  rX  rj  rm  r   r  r‡  r‰  rŠ  r‹  r  r  r  r‘  r’  r“  r”  r•  r˜  r™  rœ  r  rž  r   r¡  rŸ  rª  r©  r­  r®  r‘   r¯  r›  r²  r·  rº  r»  r#  r+  rƒ  r¼  r½  r¾  rÁ  rÂ  rÃ  rÅ  rÆ  rÈ  r„  rß  rä  r   rê  rî  rï  rð  rñ  rò  rô  r¸   r   Zdedent_interpdrë   rû  rü  rÄ   r‚  rI  rþ  rÿ  ra  rv  r!  r  r"  rp  rÀ   r  r  r  r  r  r  r  r  rb  ru  r)  r*  rq  rÁ   r  r   r!  r"  r#  r$  r'  r(  r,  r-  r.  r0  r1  r2  r3  r5  r¾   r7  r¿   r8  r9  rB  rJ  rK  rT  rÝ  r¸  rV  rW  rX  râ  rZ  r?  r@  r  r  Ú__classcell__r   r   )rÒ   r   r‡   Œ  s|        }

'

 JG-8  
,	 

P-j.M#*Y)c	( 
"$( 
!"

  #J
	 Nr‡   )Kr?  r   r8   Zloggingrk  Znumbersr   Úoperatorr   rF  rr  Znumpyr\   rñ   r   r   Zmatplotlib.cbookr   r   r	   r
   r   r   r   Zmatplotlib.colorsZcolorsr   Zmatplotlib.linesrü   r$   Zmatplotlib.patchesr7  rr   Zmatplotlib.artistrÉ  rŸ   Zmatplotlib.transformsZ
transformsr¡   Zmatplotlib.tickerZtickerr-  Zmatplotlib.axisr  rÜ   Zmatplotlib.scalerÙ  r$  Zmatplotlib.spinesr´   r  Zmatplotlib.font_managerrA  Zmatplotlib.textr  rB  Zmatplotlib.imager~  rë  Zmatplotlib.offsetboxr   r   Zmatplotlib.legendr   Zmatplotlib.rcsetupr   r   Z	getLoggerrƒ   rà  r+   rQ  r,   r    r‡   r   r   r   r   Ú<module>   sD    
\  