B
    ]”t\w½  ã               @   sŒ  d Z ddlmZmZmZ ddlZddlZddlm	Z	m
Z
mZmZmZ ddl	mZmZ ddl
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mZmZ ddlmZ ddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* dd„ Z+dd„ Z,dd„ Z-dd„ Z.e
 /dgdgdgdgdgdgdgdgdgdœ	¡G dd „ d eƒƒZ0G d!d"„ d"e1ƒZ2e0j3Z4ejZ5e0j6Z6ej7Z8ej9j:e	 ;e0¡d# e <e0j=¡ dS )$zn
This module contains all the 2D line class which can draw with a
variety of line styles, markers and colors.
é    )ÚIntegralÚNumberÚRealNé   )ÚartistÚcbookÚcolorsÚ	docstringÚrcParams)ÚArtistÚallow_rasterization)Ú_to_unmasked_float_arrayÚiterableÚ	ls_mapperÚls_mapper_rÚSTEP_LOOKUP_MAP)ÚMarkerStyle)ÚPath)ÚBboxÚTransformedPathÚIdentityTransform)Ú_path)Ú	CARETLEFTÚ
CARETRIGHTÚCARETUPÚ	CARETDOWNÚCARETLEFTBASEÚCARETRIGHTBASEÚCARETUPBASEÚCARETDOWNBASEÚTICKLEFTÚ	TICKRIGHTÚTICKUPÚTICKDOWNc             C   s˜   t | tƒrt | | ¡} | dkr(d\}}nD| dkrHd}ttd | ¡ ƒ}n$t | tƒr\| \}}ntdt| ƒ ƒ‚|dk	r|dk	rt|ƒ}|r||; }||fS )z&Convert linestyle -> dash pattern
    )ZsolidÚNone)NN)ZdashedZdashdotZdottedr   zlines.{}_patternzUnrecognized linestyle: %sN)	Ú
isinstanceÚstrr   ÚgetÚtupler
   ÚformatÚ
ValueErrorÚsum)ZstyleÚoffsetÚdashesZdsum© r.   ú/lib/python3.7/site-packages/matplotlib/lines.pyÚ_get_dash_pattern   s    



r0   c                sJ   t d s| |fS d  }}| d k	r(| ˆ  }|d k	rB‡ fdd„|D ƒ}||fS )Nzlines.scale_dashesc                s    g | ]}|d k	r|ˆ  nd ‘qS )Nr.   )Ú.0Úx)Úlwr.   r/   ú
<listcomp>B   s   z!_scale_dashes.<locals>.<listcomp>)r
   )r,   r-   r3   Zscaled_offsetZscaled_dashesr.   )r3   r/   Ú_scale_dashes:   s    
r5   c             C   sZ  t |ƒdk r8t | | d || d  |d k¡\}|S |dd… |dd…  }}|dd… | |dd… |  }}	|d |	d  }
| | | || |	  |
 }|dk|dk@ }| | d || d  |d k}||dd… |dd… B  @ }|||  |||	   }}| | d || d  |d k}||@ }| ¡  ¡ \}| ¡  ¡ \}t ||f¡S )z
    Determine if any line segments are within radius of a
    point. Returns the list of line segments that are within that
    radius.
    é   Néÿÿÿÿr   r   )ÚlenÚnpÚnonzeroÚravelZconcatenate)ZcxZcyr2   ÚyZradiusZresZxrZyrZdxZdyZLnorm_sqÚuZ
candidatesZ
point_hitsZpxÚpyZ	line_hitsZpointsÚlinesr.   r.   r/   Úsegment_hitsH   s     ("  r@   c          	   C   sœ  |j |j }}dd„ }t| tƒr*d| f} nt| tƒr<d| f} t| tƒr t| ƒdkrbtd | ¡ƒ‚| \}}t|tƒr°t|tƒsŒtd | ¡ƒ‚t	|t
|d|ƒ ||t
|d|ƒƒƒS t|tƒrt|tƒsÔtd	 | ¡ƒ‚| |j¡}	t t|	ƒdf¡}
d|
ddd…f< |	d
d…dd…f |	dd…dd…f  |
d
d…dd…f< tj|
d d
d}
t |
¡}
t |
¡}
| t ddgd
d
gg¡¡}tj|dd}t |d ¡}t |¡}t || |
d || ¡}t |
tjdd…f |dd…tjf  ¡}|jd
d}t |¡}t	|| |||ƒƒS td| f ƒ‚nxt| t
ƒr@t	||  ||| ƒƒS t| ƒrŠyt	||  ||| ƒƒS  ttfk
r†   td| f ƒ‚Y nX ntd| f ƒ‚dS )zà
    Helper function that sorts out how to deal the input
    `markevery` and returns the points where markers should be drawn.

    Takes in the `markevery` value and the line path and returns the
    sub-sampled path.
    c             S   s   | dkrdS | | S )zY
        Helper function to cope with `codes` being an
        ndarray or `None`
        Nr.   )Zin_vZslcr.   r.   r/   Ú_slice_or_noney   s    z(_mark_every_path.<locals>._slice_or_noner   g        r6   z9`markevery` is a tuple but its len is not 2; markevery={}zq`markevery` is a tuple with len 2 and second element is an int, but the first element is not an int; markevery={}Nz}`markevery` is a tuple with len 2 and second element is a float, but the first element is not a float or an int; markevery={}r   r7   )Zaxisz``markevery` is a tuple with len 2, but its second element is not an int or a float; markevery=%szR`markevery` is iterable but not a valid form of numpy fancy indexing; markevery=%sz4Value of `markevery` is not recognized; markevery=%s)ÚcodesÚverticesr%   r   r   r(   r8   r*   r)   r   ÚsliceÚ	transformr9   Úemptyr+   ZsqrtZcumsumZarrayZdiffÚarangeÚabsZnewaxisZargminÚuniquer   Ú
IndexError)Ú	markeveryÚtpathÚaffineZax_transformrB   ZvertsrA   ÚstartÚstepZdisp_coordsZdeltaÚscaleZmarker_deltaZindsr.   r.   r/   Ú_mark_every_pathn   sj    	






8


*

rQ   ZaaÚcÚlsr3   ÚmecZmewZmfcZmfcaltÚms)	ÚantialiasedÚcolorÚ	linestyleÚ	linewidthÚmarkeredgecolorÚmarkeredgewidthÚmarkerfacecolorÚmarkerfacecoloraltÚ
markersizec               @   s|  e Zd ZdZddddddddœ ZZdd	d
ddœZdd
iZee–Zee•Z	e
jZe
jZe
jZdZdZdZdd„ Zd’dd„Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zejjd*d+„ ƒZd,d-„ Z d.d/„ Z!d“d1d2„Z"d”d3d4„Z#d5d6„ Z$d7d8„ Z%d9d:„ Z&e'd;d<„ ƒZ(d=d>„ Z)d?d@„ Z*dAdB„ Z+dCdD„ Z,dEdF„ Z-dGdH„ Z.dIdJ„ Z/dKdL„ Z0d•dMdN„Z1dOdP„ Z2dQdR„ Z3dSdT„ Z4d–dVdW„Z5d—dXdY„Z6d˜dZd[„Z7d\d]„ Z8d^d_„ Z9d`da„ Z:dbdc„ Z;ddde„ Z<dfdg„ Z=dhdi„ Z>djdk„ Z?e@jAdldm„ ƒZBdndo„ ZCdpdq„ ZDdrds„ ZEdtdu„ ZFdvdw„ ZGdxdy„ ZHdzd{„ ZId|d}„ ZJd~d„ ZKd€d„ ZLd‚dƒ„ ZMd„d…„ ZNd†d‡„ ZOdˆd‰„ ZPdŠd‹„ ZQdŒd„ ZRdŽd„ ZSdd‘„ ZTdS )™ÚLine2Da  
    A line - the line can have both a solid linestyle connecting all
    the vertices, and a marker at each vertex.  Additionally, the
    drawing of the solid line is influenced by the drawstyle, e.g., one
    can create "stepped" lines in various styles.
    Z_draw_solidZ_draw_dashedZ_draw_dash_dotZ_draw_dottedÚ_draw_nothing)ú-z--z-.ú:r$   ú Ú Z_draw_linesZ_draw_steps_midZ_draw_steps_preZ_draw_steps_post)Údefaultz	steps-midz	steps-prez
steps-postÚstepsr6   )ZbuttÚroundZ
projecting)Zmiterrg   Zbevelc             C   sŽ   | j dkrd| j  S | jd kr"dS t| jƒdkrhd| jd | jd | jd | jd | jd | jd f S dd d	d
„ t| j| jƒD ƒ¡ S d S )Nrd   z
Line2D(%s)zLine2D()é   z#Line2D((%g,%g),(%g,%g),...,(%g,%g))r   r7   ú,c             S   s   g | ]\}}d ||f ‘qS )z(%g,%g)r.   )r1   r2   r<   r.   r.   r/   r4     s    z"Line2D.__str__.<locals>.<listcomp>)Z_labelÚ_xr8   Ú_yÚjoinÚzip)Úselfr.   r.   r/   Ú__str__  s    



zLine2D.__str__NÚnoneé   c             K   sö  t  | ¡ t|ƒstdƒ‚t|ƒs*tdƒ‚|dkr:td }|dkrJtd }|dkrZtd }|
dkrjtd }
|	dkrztd }	|dkrŠtd	 }|dkrštd
 }|dkrªtd }|dkrºtd }|dkrÊtd }|dkrÚtd }|dkrêtd }t|tƒrD|  |¡\}}|dk	r2|dk	r2||kr2td 	||¡ƒ‚|}|dk	rD|}|dkrRd}d| _
d| _d| _d| _|  |¡ |  |¡ |  |¡ |  |¡ d| _d| _|| _d| _d| _d| _d| _|  |¡ |  |¡ |  |¡ d| _|  |¡ t||ƒ| _d| _ d| _!d| _"|  #|¡ |  $|¡ |  %|¡ d| _&d| _'d| _(d| _)|  *|
¡ |  +|¡ |  ,|	¡ |  -|¡ d| _.|  /|¡ || _0d| _1t| j2t3ƒr˜| j2| _0t4 5g ¡| _6t4 5g ¡| _7d| _8d| _9d| _:d| _;d| _<d| _=d| _>d| _?d| _@|  A||¡ dS )a«  
        Create a :class:`~matplotlib.lines.Line2D` instance with *x*
        and *y* data in sequences *xdata*, *ydata*.

        The kwargs are :class:`~matplotlib.lines.Line2D` properties:

        %(Line2D)s

        See :meth:`set_linestyle` for a description of the line styles,
        :meth:`set_marker` for a description of the markers, and
        :meth:`set_drawstyle` for a description of the draw styles.

        zxdata must be a sequencezydata must be a sequenceNzlines.linewidthzlines.linestylezlines.markerzlines.markerfacecolorzlines.markeredgecolorzlines.colorzlines.markersizezlines.antialiasedzlines.dash_capstylezlines.dash_joinstylezlines.solid_capstylezlines.solid_joinstylez2Inconsistent drawstyle ({!r}) and linestyle ({!r})re   r   TF)Br   Ú__init__r   ÚRuntimeErrorr
   r%   r&   Ú_split_drawstyle_linestyler*   r)   Ú_dashcapstyleÚ_dashjoinstyleÚ_solidjoinstyleÚ_solidcapstyleÚset_dash_capstyleÚset_dash_joinstyleÚset_solid_capstyleÚset_solid_joinstyleZ_linestylesÚ
_drawstyleÚ
_linewidthÚ_dashSeqÚ_dashOffsetÚ_us_dashSeqÚ_us_dashOffsetÚset_linewidthÚset_linestyleÚset_drawstyleÚ_colorÚ	set_colorr   Ú_markerÚ
_markeveryÚ_markersizeÚ_antialiasedÚset_markeveryÚset_antialiasedÚset_markersizeÚ_markeredgecolorÚ_markeredgewidthÚ_markerfacecolorÚ_markerfacecoloraltÚset_markerfacecolorÚset_markerfacecoloraltÚset_markeredgecolorÚset_markeredgewidthZverticalOffsetÚupdateÚ
pickradiusÚ
ind_offsetÚ_pickerr   r9   ÚasarrayÚ_xorigÚ_yorigÚ	_invalidxÚ	_invalidyrj   rk   Ú_xyr   Ú_transformed_pathÚ	_subsliceÚ	_x_filledÚset_data)rn   ÚxdataÚydatarY   rX   rW   Úmarkerr^   r[   rZ   r\   r]   Z	fillstylerV   Zdash_capstyleZsolid_capstyleZdash_joinstyleZsolid_joinstyler˜   Ú	drawstylerK   ÚkwargsÚdsrS   r.   r.   r/   rr     s¸    "



















zLine2D.__init__c          	   C   sj  t | jƒr|  | |¡S t| jtƒs*tdƒ‚| js6| jr>|  ¡  t	| j
ƒdkrTdi fS |  ¡ }| ¡ \}}| |¡}|j}|dd…df }|dd…df }| jdkr´t d¡ | j}n| jjd | j }tjdd	r | jd
kr||j d ||j d  }	t t |	|d ¡¡\}
n*t|j|j|||ƒ}
| j d¡r@|
d }
W dQ R X |
| j7 }
t	|
ƒdkt|
dfS )a.  
        Test whether the mouse event occurred on the line.  The pick
        radius determines the precision of the location test (usually
        within five points of the value).  Use
        :meth:`~matplotlib.lines.Line2D.get_pickradius` or
        :meth:`~matplotlib.lines.Line2D.set_pickradius` to view or
        modify it.

        Returns *True* if any values are within the radius along with
        ``{'ind': pointlist}``, where *pointlist* is the set of points
        within the radius.

        TODO: sort returned indices by distance
        z pick radius should be a distancer   FNr   z,no figure set when check if mouse is on lineg      R@Úignore)Úall)r$   Nr6   rf   )Úind)ÚcallableÚ	_containsr%   r˜   r   r*   rŸ   rž   Úrecacher8   r    Ú_get_transformed_pathÚget_transformed_path_and_affineZtransform_pathrC   ÚfigureÚwarningsÚwarnÚdpir9   ZerrstateÚ
_linestyler2   r<   r:   Z
less_equalr@   r}   Ú
startswithr™   Údict)rn   Z
mouseeventZtransformed_pathÚpathrM   ÚxyZxtZytZpixelsÚdr­   r.   r.   r/   Úcontains®  s6    




zLine2D.containsc             C   s   | j S )z1return the pick radius used for containment tests)r˜   )rn   r.   r.   r/   Úget_pickradiusî  s    zLine2D.get_pickradiusc             C   s
   || _ dS )z•Set the pick radius used for containment tests.

        Parameters
        ----------
        d : float
            Pick radius, in points.
        N)r˜   )rn   r¼   r.   r.   r/   Úset_pickradiusò  s    zLine2D.set_pickradiusc             C   s
   | j  ¡ S )z-
        return the marker fillstyle
        )rˆ   Úget_fillstyle)rn   r.   r.   r/   rÀ   ü  s    zLine2D.get_fillstylec             C   s   | j  |¡ d| _dS )a  
        Set the marker fill style; 'full' means fill the whole marker.
        'none' means no filling; other options are for half-filled markers.

        Parameters
        ----------
        fs : {'full', 'left', 'right', 'bottom', 'top', 'none'}
        TN)rˆ   Úset_fillstyleÚstale)rn   Zfsr.   r.   r/   rÁ     s    	zLine2D.set_fillstylec             C   s   | j |krd| _|| _ dS )aú  Set the markevery property to subsample the plot when using markers.

        e.g., if `every=5`, every 5-th marker will be plotted.

        Parameters
        ----------
        every: None or int or (int, int) or slice or List[int] or float or (float, float)
            Which markers to plot.

            - every=None, every point will be plotted.
            - every=N, every N-th marker will be plotted starting with
              marker 0.
            - every=(start, N), every N-th marker, starting at point
              start, will be plotted.
            - every=slice(start, end, N), every N-th marker, starting at
              point start, up to but not including point end, will be plotted.
            - every=[i, j, m, n], only markers at points i, j, m, and n
              will be plotted.
            - every=0.1, (i.e. a float) then markers will be spaced at
              approximately equal distances along the line; the distance
              along the line between markers is determined by multiplying the
              display-coordinate distance of the axes bounding-box diagonal
              by the value of every.
            - every=(0.5, 0.1) (i.e. a length-2 tuple of float), the
              same functionality as every=0.1 is exhibited but the first
              marker will be 0.5 multiplied by the
              display-cordinate-diagonal-distance along the line.

        Notes
        -----
        Setting the markevery property will only show markers at actual data
        points.  When using float arguments to set the markevery property
        on irregularly spaced data, the markers will likely not appear evenly
        spaced because the actual data points do not coincide with the
        theoretical spacing between markers.

        When using a start offset to specify the first marker, the offset will
        be from the first data point which may be different from the first
        the visible data point if the plot is zoomed in.

        If zooming in on a plot when using float arguments then the actual
        data points that have markers will change because the distance between
        markers is always determined from the display-coordinates
        axes-bounding-box-diagonal regardless of the actual axes data limits.

        TN)r‰   rÂ   )rn   Zeveryr.   r.   r/   rŒ     s    0
zLine2D.set_markeveryc             C   s   | j S )zreturn the markevery setting)r‰   )rn   r.   r.   r/   Úget_markeveryB  s    zLine2D.get_markeveryc             C   s    t |ƒr|| _n|| _|| _dS )zÞSets the event picker details for the line.

        Parameters
        ----------
        p : float or callable[[Artist, Event], Tuple[bool, dict]]
            If a float, it is used as the pick radius in points.
        N)r®   r¯   r˜   rš   )rn   Úpr.   r.   r/   Ú
set_pickerF  s    zLine2D.set_pickerc             C   s^   t ddgddggƒ}|  ¡ j}|j||  ¡ ƒdd | jrZ| jd | jj d }| 	|¡}|S )Nr   T)r«   g      R@g      à?)
r   Úget_transformrE   Zupdate_from_data_xyÚ
get_xydatarˆ   rŠ   r³   r¶   Zpadded)rn   ÚrendererZbboxZtrans_data_to_xyrU   r.   r.   r/   Úget_window_extentT  s    

zLine2D.get_window_extentc             C   sV   t j | |¡ |d k	rR|jd k	r4|jj d| j¡| _|jd k	rR|jj d| j¡| _	d S )NZunits)
r   ÚaxesÚfsetZxaxisZ	callbacksZconnectÚrecache_alwaysZ_xcidZyaxisZ_ycid)rn   Zaxr.   r.   r/   rÊ   _  s    




zLine2D.axesc             G   s:   t |ƒdkr|d \}}n|\}}|  |¡ |  |¡ dS )zb
        Set the x and y data

        ACCEPTS: 2D array (rows are x, y) or two 1D arrays
        r   r   N)r8   Ú	set_xdataÚ	set_ydata)rn   Úargsr2   r<   r.   r.   r/   r¤   l  s
    
zLine2D.set_datac             C   s   | j dd d S )NT)Úalways)r°   )rn   r.   r.   r/   rÌ   z  s    zLine2D.recache_alwaysFc       
      C   sš  |s
| j r$|  | j¡}t|ƒ ¡ }n| j}|s4| jrN|  | j¡}t|ƒ ¡ }n| j	}t
 t
 ||¡¡ t¡| _| jj\| _| _	d| _| jrBt|ƒdkrB|  |¡rB| jjdkrB| j ¡ dkrB| jd krB|  ¡ dkrBd| _t
 |¡}| ¡ r:| j ¡ | _t
 t|ƒ¡}t
 || ||  | j|  ¡| j|< n| j| _| jd k	rX| jj }nd}t!| j" | jjŽ }	t#t
 $|	¡j|d| _d | _%d| _ d| _d S )NFiè  ZrectilinearZlinearTr   )Ú_interpolation_steps)&rž   Zconvert_xunitsrœ   r   r;   rj   rŸ   Zconvert_yunitsr   rk   r9   Zcolumn_stackZbroadcast_arraysZastypeÚfloatr    ÚTr¢   rÊ   r8   Ú
_is_sortedÚnameZ
get_xscaler‰   Zget_clip_onZisnanÚanyÚcopyr£   rG   Zinterpr   rÑ   r   r}   r   r›   r¡   )
rn   rÐ   Zxconvr2   Zyconvr<   ZnanmaskÚindicesZinterpolation_stepsr»   r.   r.   r/   r°   }  sB    

"




zLine2D.recachec             C   sZ   |dk	r@t | j | j|dd…f jŽ }tt |¡j| jjd}n| j}t	||  
¡ ƒ| _dS )z¯
        Puts a TransformedPath instance at self._transformed_path;
        all invalidation of the transform is then handled by the
        TransformedPath instance.
        N)rÑ   )r   r}   r    rÓ   r   r9   r›   r   rÑ   r   rÆ   r¡   )rn   Úsubslicer»   r   r.   r.   r/   Ú_transform_path§  s    zLine2D._transform_pathc             C   s   | j dkr|  ¡  | j S )zk
        Return the :class:`~matplotlib.transforms.TransformedPath` instance
        of this line.
        N)r¡   rÚ   )rn   r.   r.   r/   r±   ¶  s    
zLine2D._get_transformed_pathc             C   s"   t  | |¡ d| _d| _d| _dS )z˜
        set the Transformation instance used by this artist

        Parameters
        ----------
        t : matplotlib.transforms.Transform
        TN)r   Úset_transformrž   rŸ   rÂ   )rn   Útr.   r.   r/   rÛ   ¿  s    zLine2D.set_transformc             C   s
   t  |¡S )z-return True if x is sorted in ascending order)r   Z	is_sorted)rn   r2   r.   r.   r/   rÔ   Ì  s    zLine2D._is_sortedc          	   C   sP  |   ¡ sdS | js| jr |  ¡  d| _| jr| jr| j ¡ \}}| j 	|gd¡\}| j 	|gd¡\}t
t|d dƒ|d ƒ}|j| _|  |¡ nd}|  ¡ r¶ddlm} ||  ¡ |ƒ}| d|  ¡ ¡ | j| j dkrÈ|  ¡  ¡ \}}	t|jƒrÈ| ¡ }
|  |
¡ t | j| j¡}|
j|d	d
 |
  | j!¡ |
 "| j#¡ |  $¡ rT| j%}| j&}n| j'}| j(}|
 )|¡ |
 *|¡ |
 +|  ,¡ ¡ |  -¡ dk	rž|
j.|  -¡ Ž  |
 /| j0| j1¡ | 2|
||	 3¡ ¡ |
 4¡  | j5r<| j6dkr<| ¡ }
|  |
¡ |
 "| j7¡ |
  | j!¡ t |  8¡ | j¡}t |  9¡ | j¡}t | j9d	d| j¡}t: ;| j<d¡rxt: =|  >¡ d¡sx|dd… |d f }|
j|d	d
 |  -¡ dk	r¼|  -¡ \}}}|
 .|d |d d| ¡ | j5}|  ?¡ dkrt:j@| ddd( |  ¡  |  |¡ |  ¡  ¡ \}}	W dQ R X n|  ¡  ¡ \}}	t|jƒr4|  A¡ }|dk	rRtB|||	| jjCƒ}n|}| D¡ }tE|tFƒrz| G| j6¡|k}|
 +|¡ |
 )| H¡ ¡ |
 *| I¡ ¡ | J¡ }| K¡ }| G| j6¡}t: ;| L¡ d¡rÚ|
 "d¡ n
| M|¡}| N|
||||	 3¡ |¡ | O¡ }|r4| P¡ }| M|¡}| N|
||||	 3¡ |¡ |
 4¡  | Qd¡ d| _RdS )z8draw the Line with `renderer` unless visibility is FalseNr   ÚleftÚrightr   )ÚPathEffectRendererZline2dr`   T)ZisRGBA)ÚaltÚautorp   rh   r6   re   )r}   r¡   ri   F)SZget_visiblerŸ   rž   r°   r™   r¢   rÊ   Z
get_xboundr£   ZsearchsortedrD   ÚmaxrN   rÚ   Zget_path_effectsZmatplotlib.patheffectsrß   Z
open_groupZget_gidÚ_lineStylesr·   r±   r²   r8   rC   Znew_gcZ_set_gc_clipÚmcolorsZto_rgbar†   Z_alphaZset_foregroundr   r‹   rƒ   r~   Ú	is_dashedru   rv   rx   rw   Zset_joinstyleZset_capstyleZset_snapZget_snapZget_sketch_paramsZset_sketch_paramsÚ
set_dashesr€   r   Z	draw_pathÚfrozenZrestorerˆ   rŠ   r   Úget_markeredgecolorÚ_get_markerfacecolorr   Ú
_str_equalr   Ú_str_lower_equalÚget_markerfacecolorÚget_drawstyleZ_setattr_cmrÃ   rQ   Z	transAxesZget_snap_thresholdr%   r   Zpoints_to_pixelsZget_joinstyleZget_capstyleÚget_pathrÆ   Ú
get_markerrP   Zdraw_markersZget_alt_pathZget_alt_transformZclose_grouprÂ   )rn   rÈ   Zx0Zx1Zi0Zi1rÙ   rß   rL   rM   ÚgcZlc_rgbaZcaprl   Zec_rgbaZfc_rgbaZ
fcalt_rgbarP   ÚlengthZ
randomnessr§   rK   Z
subsampledZsnapZmarker_pathZmarker_transÚwZalt_marker_pathZalt_marker_transr.   r.   r/   ÚdrawÑ  sÂ    











zLine2D.drawc             C   s   | j S )N)r‹   )rn   r.   r.   r/   Úget_antialiasedU  s    zLine2D.get_antialiasedc             C   s   | j S )N)r†   )rn   r.   r.   r/   Ú	get_colorX  s    zLine2D.get_colorc             C   s   | j S )N)r}   )rn   r.   r.   r/   rí   [  s    zLine2D.get_drawstylec             C   s   | j S )N)r·   )rn   r.   r.   r/   Úget_linestyle^  s    zLine2D.get_linestylec             C   s   | j S )N)r~   )rn   r.   r.   r/   Úget_linewidtha  s    zLine2D.get_linewidthc             C   s
   | j  ¡ S )N)rˆ   rï   )rn   r.   r.   r/   rï   d  s    zLine2D.get_markerc             C   sV   | j }t |d¡rNtd rH| j ¡ dkr.| jS | j ¡ rH|  ¡ dkrHdS | jS |S d S )Nrá   z_internal.classic_mode)Ú.ri   rp   Úk)	r   r   rê   r
   rˆ   rï   r†   Z	is_filledrÀ   )rn   rT   r.   r.   r/   rè   g  s    zLine2D.get_markeredgecolorc             C   s   | j S )N)r   )rn   r.   r.   r/   Úget_markeredgewidths  s    zLine2D.get_markeredgewidthc             C   s<   |r
| j n| j}t |d¡r4|  ¡ dkr,dS | jS n|S d S )Nrá   rp   )r’   r‘   r   rë   rÀ   r†   )rn   rà   Úfcr.   r.   r/   ré   v  s    zLine2D._get_markerfacecolorc             C   s   | j ddS )NF)rà   )ré   )rn   r.   r.   r/   rì   €  s    zLine2D.get_markerfacecolorc             C   s   | j ddS )NT)rà   )ré   )rn   r.   r.   r/   Úget_markerfacecoloraltƒ  s    zLine2D.get_markerfacecoloraltc             C   s   | j S )N)rŠ   )rn   r.   r.   r/   Úget_markersize†  s    zLine2D.get_markersizeTc             C   s   | j |d| j|dfS )zb
        Return the xdata, ydata.

        If *orig* is *True*, return the original data.
        )Úorig)Ú	get_xdataÚ	get_ydata)rn   rþ   r.   r.   r/   Úget_data‰  s    zLine2D.get_datac             C   s   |r
| j S | jr|  ¡  | jS )z|
        Return the xdata.

        If *orig* is *True*, return the original data, else the
        processed data.
        )rœ   rž   r°   rj   )rn   rþ   r.   r.   r/   rÿ   ‘  s
    zLine2D.get_xdatac             C   s   |r
| j S | jr|  ¡  | jS )z|
        Return the ydata.

        If *orig* is *True*, return the original data, else the
        processed data.
        )r   rŸ   r°   rk   )rn   rþ   r.   r.   r/   r   ž  s
    zLine2D.get_ydatac             C   s   | j s| jr|  ¡  | jS )ze
        Return the :class:`~matplotlib.path.Path` object associated
        with this line.
        )rŸ   rž   r°   r   )rn   r.   r.   r/   rî   «  s    zLine2D.get_pathc             C   s   | j s| jr|  ¡  | jS )z<
        Return the *xy* data as a Nx2 numpy array.
        )rŸ   rž   r°   r    )rn   r.   r.   r/   rÇ   ´  s    zLine2D.get_xydatac             C   s   | j |krd| _|| _ dS )zs
        Set whether to use antialiased rendering.

        Parameters
        ----------
        b : bool
        TN)r‹   rÂ   )rn   Úbr.   r.   r/   r   ¼  s    
zLine2D.set_antialiasedc             C   s   || _ d| _dS )zh
        Set the color of the line

        Parameters
        ----------
        color : color
        TN)r†   rÂ   )rn   rW   r.   r.   r/   r‡   È  s    zLine2D.set_colorc             C   sD   |dkrd}|| j kr$td |¡ƒ‚| j|kr:d| _d| _|| _dS )ad  
        Set the drawstyle of the plot

        'default' connects the points with lines. The steps variants
        produce step-plots. 'steps' is equivalent to 'steps-pre' and
        is maintained for backward-compatibility.

        Parameters
        ----------
        drawstyle : {'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}
        Nre   zUnrecognized drawstyle {!r}T)Ú
drawStylesr*   r)   r}   rÂ   rž   )rn   r¨   r.   r.   r/   r…   Ó  s    

zLine2D.set_drawstylec             C   s<   t |ƒ}| j|krd| _|| _t| j| j| jƒ\| _| _dS )zg
        Set the line width in points

        Parameters
        ----------
        w : float
        TN)rÒ   r~   rÂ   r5   r‚   r   r€   r   )rn   rò   r.   r.   r/   rƒ   ê  s    
zLine2D.set_linewidthc             C   s:   x0| j D ]&}| |¡r||t|ƒd… p*dfS qW d|fS )aì  Split drawstyle from linestyle string

        If `ls` is only a drawstyle default to returning a linestyle
        of '-'.

        Parameters
        ----------
        ls : str
            The linestyle to be processed

        Returns
        -------
        ret_ds : str or None
            If the linestyle string does not contain a drawstyle prefix
            return None, otherwise return it.

        ls : str
            The linestyle with the drawstyle (if any) stripped.
        Nra   )ÚdrawStyleKeysr¸   r8   )rn   rS   rª   r.   r.   r/   rt   û  s    
z!Line2D._split_drawstyle_linestylec             C   s¬   t |tƒrx|  |¡\}}|dk	r*|  |¡ |dkr6d}|| jkrpyt| }W n" tk
rn   td |¡ƒ‚Y nX || _	nd| _	t
|ƒ\| _| _t| j| j| jƒ\| _| _dS )aÈ  
        Set the linestyle of the line (also accepts drawstyles,
        e.g., ``'steps--'``)


        ===========================   =================
        linestyle                     description
        ===========================   =================
        ``'-'`` or ``'solid'``        solid line
        ``'--'`` or  ``'dashed'``     dashed line
        ``'-.'`` or  ``'dashdot'``    dash-dotted line
        ``':'`` or ``'dotted'``       dotted line
        ``'None'``                    draw nothing
        ``' '``                       draw nothing
        ``''``                        draw nothing
        ===========================   =================

        'steps' is equivalent to 'steps-pre' and is maintained for
        backward-compatibility.

        Alternatively a dash tuple of the following form can be provided::

            (offset, onoffseq),

        where ``onoffseq`` is an even length tuple of on and off ink in points.

        .. seealso::

            :meth:`set_drawstyle`
               To set the drawing style (stepping) of the plot.

        Parameters
        ----------
        ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
            The line style.
        N)rc   rd   rp   r$   zIInvalid linestyle {!r}; see docs of Line2D.set_linestyle for valid valuesz--)r%   r&   rt   r…   rã   r   ÚKeyErrorr*   r)   r·   r0   r‚   r   r5   r~   r€   r   )rn   rS   rª   r.   r.   r/   r„     s"    %


zLine2D.set_linestylec             C   s   | j  |¡ d| _dS )zÈ
        Set the line marker.

        Parameters
        ----------
        marker: marker style
            See `~matplotlib.markers` for full description of possible
            arguments.
        TN)rˆ   Ú
set_markerrÂ   )rn   r§   r.   r.   r/   r  R  s    zLine2D.set_markerc             C   s6   |dkrd}| j dks&t | j |k¡r,d| _|| _ dS )zf
        Set the marker edge color.

        Parameters
        ----------
        ec : color
        Nrá   T)r   r9   rÖ   rÂ   )rn   Zecr.   r.   r/   r•   `  s    
zLine2D.set_markeredgecolorc             C   s*   |dkrt d }| j|kr d| _|| _dS )zp
        Set the marker edge width in points.

        Parameters
        ----------
        ew : float
        Nzlines.markeredgewidthT)r
   r   rÂ   )rn   Zewr.   r.   r/   r–   o  s
    
zLine2D.set_markeredgewidthc             C   s,   |dkrd}t  | j|k¡r"d| _|| _dS )zf
        Set the marker face color.

        Parameters
        ----------
        fc : color
        Nrá   T)r9   rÖ   r‘   rÂ   )rn   rû   r.   r.   r/   r“   }  s
    zLine2D.set_markerfacecolorc             C   s,   |dkrd}t  | j|k¡r"d| _|| _dS )zp
        Set the alternate marker face color.

        Parameters
        ----------
        fc : color
        Nrá   T)r9   rÖ   r’   rÂ   )rn   rû   r.   r.   r/   r”   ‹  s
    zLine2D.set_markerfacecoloraltc             C   s"   t |ƒ}| j|krd| _|| _dS )zj
        Set the marker size in points.

        Parameters
        ----------
        sz : float
        TN)rÒ   rŠ   rÂ   )rn   Zszr.   r.   r/   rŽ   ™  s    
zLine2D.set_markersizec             C   s   || _ d| _d| _dS )zg
        Set the data array for x.

        Parameters
        ----------
        x : 1D array
        TN)rœ   rž   rÂ   )rn   r2   r.   r.   r/   rÍ   ¦  s    zLine2D.set_xdatac             C   s   || _ d| _d| _dS )zg
        Set the data array for y.

        Parameters
        ----------
        y : 1D array
        TN)r   rŸ   rÂ   )rn   r<   r.   r.   r/   rÎ   ²  s    zLine2D.set_ydatac             C   s2   |dkst |ƒdkr |  d¡ n|  d|f¡ dS )a$  
        Set the dash sequence, sequence of dashes with on off ink in
        points.  If seq is empty or if seq = (None, None), the
        linestyle will be set to solid.

        Parameters
        ----------
        seq : sequence of floats (on/off ink in points) or (None, None)
        )NNr   ra   N)r8   r„   )rn   Úseqr.   r.   r/   ræ   ¾  s    
zLine2D.set_dashesc             C   s¸   t  | |¡ |j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	|j
| _
|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _t|j ¡ |j ¡ ƒ| _|j| _dS )z"copy properties from other to selfN)r   Úupdate_fromr·   r~   r†   rŠ   r‘   r’   r   r   r   r   r€   r‚   ru   rv   rx   rw   r   rˆ   rï   rÀ   r}   )rn   Úotherr.   r.   r/   r  Í  s*    
zLine2D.update_fromc             C   sF   |  ¡ }|| jkr,td|f d| jf  ƒ‚| j|kr<d| _|| _dS )zŠ
        Set the join style for dashed linestyles.

        Parameters
        ----------
        s : {'miter', 'round', 'bevel'}
        z set_dash_joinstyle passed "%s";
zvalid joinstyles are %sTN)ÚlowerÚ	validJoinr*   rv   rÂ   )rn   Úsr.   r.   r/   rz   æ  s    


zLine2D.set_dash_joinstylec             C   sF   |  ¡ }|| jkr,td|f d| jf  ƒ‚| j|kr<d| _|| _dS )z‰
        Set the join style for solid linestyles.

        Parameters
        ----------
        s : {'miter', 'round', 'bevel'}
        z!set_solid_joinstyle passed "%s";
zvalid joinstyles are %sTN)r
  r  r*   rw   rÂ   )rn   r  r.   r.   r/   r|   ö  s    


zLine2D.set_solid_joinstylec             C   s   | j S )z:
        Get the join style for dashed linestyles
        )rv   )rn   r.   r.   r/   Úget_dash_joinstyle  s    zLine2D.get_dash_joinstylec             C   s   | j S )z9
        Get the join style for solid linestyles
        )rw   )rn   r.   r.   r/   Úget_solid_joinstyle  s    zLine2D.get_solid_joinstylec             C   sF   |  ¡ }|| jkr,td|f d| jf  ƒ‚| j|kr<d| _|| _dS )z
        Set the cap style for dashed linestyles.

        Parameters
        ----------
        s : {'butt', 'round', 'projecting'}
        zset_dash_capstyle passed "%s";
zvalid capstyles are %sTN)r
  ÚvalidCapr*   ru   rÂ   )rn   r  r.   r.   r/   ry     s    


zLine2D.set_dash_capstylec             C   sF   |  ¡ }|| jkr,td|f d| jf  ƒ‚| j|kr<d| _|| _dS )zŒ
        Set the cap style for solid linestyles.

        Parameters
        ----------
        s : {'butt', 'round', 'projecting'}
        z set_solid_capstyle passed "%s";
zvalid capstyles are %sTN)r
  r  r*   rx   rÂ   )rn   r  r.   r.   r/   r{   #  s    


zLine2D.set_solid_capstylec             C   s   | j S )z9
        Get the cap style for dashed linestyles
        )ru   )rn   r.   r.   r/   Úget_dash_capstyle3  s    zLine2D.get_dash_capstylec             C   s   | j S )z8
        Get the cap style for solid linestyles
        )rx   )rn   r.   r.   r/   Úget_solid_capstyle9  s    zLine2D.get_solid_capstylec             C   s
   | j dkS )z return True if line is dashstyle)z--z-.rb   )r·   )rn   r.   r.   r/   rå   ?  s    zLine2D.is_dashed)NNNNNNNNrp   NNNNNNrq   NN)F)N)F)T)T)T)UÚ__name__Ú
__module__Ú__qualname__Ú__doc__Ú
lineStylesrã   Z_drawStyles_lZ_drawStyles_sr  r  r   ÚmarkersZfilled_markersÚ
fillstylesÚ
fillStylesZzorderr  r  ro   rr   r½   r¾   r¿   rÀ   rÁ   rŒ   rÃ   rÅ   rÉ   r   rÊ   Úsetterr¤   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ƒ   rt   r„   r	   Údedent_interpdr  r•   r–   r“   r”   rŽ   rÍ   rÎ   ræ   r  rz   r|   r  r  ry   r{   r  r  rå   r.   r.   r.   r/   r_   Ð   sÌ                    
 @
4
*
	 




	>r_   c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚVertexSelectoraá  
    Manage the callbacks to maintain a list of selected vertices for
    :class:`matplotlib.lines.Line2D`. Derived classes should override
    :meth:`~matplotlib.lines.VertexSelector.process_selected` to do
    something with the picks.

    Here is an example which highlights the selected verts with red
    circles::

        import numpy as np
        import matplotlib.pyplot as plt
        import matplotlib.lines as lines

        class HighlightSelected(lines.VertexSelector):
            def __init__(self, line, fmt='ro', **kwargs):
                lines.VertexSelector.__init__(self, line)
                self.markers, = self.axes.plot([], [], fmt, **kwargs)

            def process_selected(self, ind, xs, ys):
                self.markers.set_data(xs, ys)
                self.canvas.draw()

        fig, ax = plt.subplots()
        x, y = np.random.rand(2, 30)
        line, = ax.plot(x, y, 'bs-', picker=5)

        selector = HighlightSelected(line)
        plt.show()

    c             C   s^   |j dkrtdƒ‚| ¡ dkr&tdƒ‚|j | _ || _| j jj| _| j d| j¡| _t	ƒ | _
dS )zê
        Initialize the class with a :class:`matplotlib.lines.Line2D`
        instance.  The line should already be added to some
        :class:`matplotlib.axes.Axes` instance and should have the
        picker property set.
        Nz'You must first add the line to the Axesz2You must first set the picker property of the lineZ
pick_event)rÊ   rs   Z
get_pickerÚliner³   ZcanvasZmpl_connectÚonpickZcidÚsetr­   )rn   r  r.   r.   r/   rr   c  s    
zVertexSelector.__init__c             C   s   dS )zã
        Default "do nothing" implementation of the
        :meth:`process_selected` method.

        *ind* are the indices of the selected vertices.  *xs* and *ys*
        are the coordinates of the selected vertices.
        Nr.   )rn   r­   ZxsZysr.   r.   r/   Úprocess_selectedx  s    zVertexSelector.process_selectedc             C   sV   |j | jk	rdS |  jt|jƒN  _t| jƒ}| j ¡ \}}|  ||| || ¡ dS )z<When the line is picked, update the set of selected indices.N)r   r  r­   r  Úsortedr  r   )rn   Zeventr­   r¥   r¦   r.   r.   r/   r  ‚  s    
zVertexSelector.onpickN)r  r  r  r  rr   r   r  r.   r.   r.   r/   r  D  s   
r  )r_   )>r  Znumbersr   r   r   r´   Znumpyr9   rd   r   r   r   rä   r	   r
   r   r   r   r   r   r   r   r  r   rº   r   Z
transformsr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r0   r5   r@   rQ   Z_define_aliasesr_   Úobjectr  rã   r  ZlineMarkersr  r  r  Zinterpdr—   Zkwdocr  rr   r.   r.   r.   r/   Ú<module>   sR   8&b        qH