3
6Ad]ÜÇ  ã               @   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 ddlmZ dd	lmZ dd
l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( ej)e*ƒZ+dd„ Z,dd„ Z-dd„ Z.dd„ Z/e
j0dgdgdgdgdgdgdgdgdgdgdœ
ƒG d d!„ d!eƒƒZ1G d"d#„ d#e2ƒZ3e1j4Z5ejZ6e1j7Z7ej8Z9ej:j;e	j<e1ƒd$� ej=e1j>ƒ 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Ú	ls_mapperÚls_mapper_rÚSTEP_LOOKUP_MAP)ÚMarkerStyle)ÚPath)ÚBboxÚTransformedPath)Ú_path)Ú	CARETLEFTÚ
CARETRIGHTÚCARETUPÚ	CARETDOWNÚCARETLEFTBASEÚCARETRIGHTBASEÚCARETUPBASEÚCARETDOWNBASEÚTICKLEFTÚ	TICKRIGHTÚTICKUPÚTICKDOWNc             C   s˜   t | tƒrtj| | ƒ} | d
kr(d\}}nD| dkrHd}ttdj| ƒ ƒ}n$t | tƒr\| \}}ntd	t| ƒ ƒ‚|dk	r�|dk	r�t|ƒ}|r�||; }||fS )z&Convert linestyle -> dash pattern
    ÚsolidÚNoneNÚdashedÚdashdotÚdottedr   zlines.{}_patternzUnrecognized linestyle: %s)r"   r#   )NN)r$   r%   r&   )	Ú
isinstanceÚstrr   ÚgetÚtupler
   ÚformatÚ
ValueErrorÚsum)ÚstyleÚoffsetÚdashesÚdsum© r2   ú{/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/matplotlib-3.1.1-py3.6-linux-x86_64.egg/matplotlib/lines.pyÚ_get_dash_pattern   s    



r4   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 )Nr2   )Ú.0Úx)Úlwr2   r3   ú
<listcomp>C   s   z!_scale_dashes.<locals>.<listcomp>)r
   )r/   r0   r7   Zscaled_offsetZscaled_dashesr2   )r7   r3   Ú_scale_dashes;   s    
r9   c             C   sZ  t |ƒdkr8tj| | 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}||@ }|jƒ jƒ \}|jƒ jƒ \}tj||fƒS )z›
    Return the indices of the segments in the polyline with coordinates (*cx*,
    *cy*) that are within a distance *radius* of the point (*x*, *y*).
    r   é   Nr   éÿÿÿÿr;   r;   )ÚlenÚnpÚnonzeroÚravelÚconcatenate)ÚcxÚcyr6   ÚyÚradiusÚresÚxrZyrÚdxÚdyZLnorm_sqÚuÚ
candidatesZ
point_hitsZpxÚpyZ	line_hitsÚpointsÚlinesr2   r2   r3   Úsegment_hitsI   s     ("  rN   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j| ƒƒ‚| \}}t|tƒr°t|tƒsŒtdj| ƒƒ‚t	|t
|d|ƒ ||t
|d|ƒƒƒS t|tƒ�rt|tƒsÔtd	j| ƒƒ‚|j|jƒ}	tj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j|
ƒ}
tj|
ƒ}
|jtjddgd
d
ggƒƒ}tj|dd�}tj|d ƒ}tj|ƒ}tj|| |
d || ƒ}tj|
tjdd…f |dd…tjf  ƒ}|jd
d�}tj|ƒ}t	|| |||ƒƒS td| ›d�ƒ‚n~t| t
ƒ�rBt	||  ||| ƒƒS tj| ƒ�r�yt	||  ||| ƒƒS  ttfk
�rŒ   td| ›d�ƒ‚Y nX ntd| ›d�ƒ‚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`
        Nr2   )Zin_vZslcr2   r2   r3   Ú_slice_or_noney   s    z(_mark_every_path.<locals>._slice_or_noner   g        r:   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   )Úaxisz
markevery=zG is a tuple with len 2, but its second element is not an int or a floatz. is iterable but not a valid numpy fancy indexz is not a recognized valuer;   r;   )ÚcodesÚverticesr'   r   r   r*   r<   r,   r+   r   ÚsliceÚ	transformr=   Úemptyr-   ÚsqrtÚcumsumÚarrayÚdiffÚarangeÚabsÚnewaxisÚargminÚuniqueÚiterableÚ
IndexError)Ú	markeveryÚtpathÚaffineZax_transformrQ   ÚvertsrO   ÚstartÚstepZdisp_coordsÚdeltaÚscaleZmarker_deltaÚindsr2   r2   r3   Ú_mark_every_pathn   sd    	






8


*
rj   ÚaaÚcÚdsÚlsr7   ÚmecÚmewÚmfcZmfcaltÚms)
ÚantialiasedÚcolorÚ	drawstyleÚ	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ejdƒedd„ ƒƒZdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Z e!j"j#d0d1„ ƒZ"d2d3„ Z$d4d5„ Z%d›d7d8„Z&dœd9d:„Z'd;d<„ Z(d=d>„ Z)d?d@„ Z*e+dAdB„ ƒZ,dCdD„ Z-dEdF„ Z.dGdH„ Z/dIdJ„ Z0dKdL„ Z1dMdN„ Z2dOdP„ Z3dQdR„ Z4d�dSdT„Z5dUdV„ Z6dWdX„ Z7dYdZ„ Z8džd\d]„Z9dŸd^d_„Z:d d`da„Z;dbdc„ Z<ddde„ Z=dfdg„ Z>dhdi„ Z?djdk„ Z@dldm„ ZAdndo„ ZBdpdq„ ZCeDjEdrds„ ƒZFdtdu„ ZGdvdw„ ZHdxdy„ ZIdzd{„ ZJd|d}„ ZKd~d„ ZLd€d�„ ZMd‚dƒ„ ZNd„d…„ ZOd†d‡„ ZPdˆd‰„ ZQdŠd‹„ ZRdŒd�„ ZSdŽd�„ ZTd�d‘„ ZUd’d“„ ZVd”d•„ ZWd–d—„ ZXd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Ústepsr:   ÚbuttÚroundÚ
projectingÚmiterÚbevelc             C   sŒ   | j dkrd| j › d�S | jd kr&dS t| jƒdkrld| jd | jd | jd | jd | jd | jd f S d	d
jtdj| j| jƒƒ S d S )Nr‚   zLine2D(ú)zLine2D()é   z#Line2D((%g,%g),(%g,%g),...,(%g,%g))r   r   z
Line2D(%s)ú,z({:g},{:g})r;   r;   )Ú_labelÚ_xr<   Ú_yÚjoinÚmapr+   )Úselfr2   r2   r3   Ú__str__  s    

zLine2D.__str__NÚnoneé   c             K   sô  t j| ƒ tj|ƒstdƒ‚tj|ƒs.tdƒ‚|dkr>td }|dkrNtd }|dkr^td }|
dkrnt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 }|dkrîtd }t|tƒ�rH| j|ƒ\}}|dk	�r6|dk	�r6||k�r6t	dj
||ƒƒ‚|}|dk	�rH|}|dk�rVd}d| _d| _d| _d| _| j|ƒ | j|ƒ | j|ƒ | j|ƒ d| _d| _|| _d| _d| _d| _d| _| j|ƒ | j|ƒ | j|ƒ d| _| j|ƒ t||ƒ| _ d| _!d| _"d| _#| j$|ƒ | j%|ƒ | j&|ƒ d| _'d| _(d| _)d| _*| j+|
ƒ | j,|ƒ | j-|	ƒ | j.|ƒ | j/|ƒ || _0d| _1t| j2t3ƒ�r–| j2| _0tj4g ƒ| _5tj4g ƒ| _6d| _7d| _8d| _9d| _:d| _;d| _<d| _=d| _>d| _?| j@||ƒ 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_docstr)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})rƒ   r   TF)Ar   Ú__init__r=   r_   ÚRuntimeErrorr
   r'   r(   Ú_split_drawstyle_linestyler,   r+   Ú_dashcapstyleÚ_dashjoinstyleÚ_solidjoinstyleÚ_solidcapstyleÚset_dash_capstyleÚset_dash_joinstyleÚset_solid_capstyleÚset_solid_joinstyleÚ_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_markeredgewidthÚupdateÚ
pickradiusÚ
ind_offsetÚ_pickerr   ÚasarrayÚ_xorigÚ_yorigÚ	_invalidxÚ	_invalidyrŽ   r�   Ú_xyr   Ú_transformed_pathÚ	_subsliceÚ	_x_filledÚset_data)r’   ÚxdataÚydatarw   rv   rt   Úmarkerr|   ry   rx   rz   r{   Ú	fillstylers   Zdash_capstyleZsolid_capstyleZdash_joinstyleZsolid_joinstyler½   ru   ra   Úkwargsrm   rn   r2   r2   r3   r–     s¶    "





















zLine2D.__init__z3.1c             C   s   d S )Nr2   )r’   r2   r2   r3   ÚverticalOffset¨  s    zLine2D.verticalOffsetc       
      C   sb  t | jƒr| j| |ƒS t| jtƒs*tdƒ‚| js6| jr>| jƒ  t	| j
ƒdkrTdi fS | jƒ }|jƒ \}}|j|ƒ}|j}|dd…df }|dd…df }| jdkr´tjdƒ | j}n| jjd | j }tjdd	��j | jdk�rtj||j d ||j d  |d kƒ\}	n*t|j|j|||ƒ}	| jjdƒ�r8|	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.

        Parameters
        ----------
        mouseevent : `matplotlib.backend_bases.MouseEvent`

        Returns
        -------
        contains : bool
            Whether any values are within the radius.
        details : dict
            A dictionary ``{'ind': pointlist}``, where *pointlist* is a
            list of points of the line that are within the pickradius around
            the event position.

            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)Úallr#   r:   r„   )Úind)r#   N)ÚcallableÚ	_containsr'   r½   r   r,   rÄ   rÃ   Úrecacher<   rÅ   Ú_get_transformed_pathÚget_transformed_path_and_affineÚtransform_pathrR   ÚfigureÚ_logÚwarningÚdpir=   ÚerrstateÚ
_linestyler>   r6   rC   rN   r¢   Ú
startswithr¾   Údict)
r’   Ú
mouseeventZtransformed_pathÚpathrc   ÚxyÚxtÚytZpixelsrÒ   r2   r2   r3   Úcontains­  s8    




zLine2D.containsc             C   s   | j S )zo
        Return the pick radius used for containment tests.

        See `.contains` for more details.
        )r½   )r’   r2   r2   r3   Úget_pickradiusõ  s    zLine2D.get_pickradiusc             C   s
   || _ dS )zÀSet the pick radius used for containment tests.

        See `.contains` for more details.

        Parameters
        ----------
        d : float
            Pick radius, in points.
        N)r½   )r’   Údr2   r2   r3   Úset_pickradiusý  s    
zLine2D.set_pickradiusc             C   s
   | j jƒ S )z[
        Return the marker fill style.

        See also `~.Line2D.set_fillstyle`.
        )r­   Úget_fillstyle)r’   r2   r2   r3   rê   	  s    zLine2D.get_fillstylec             C   s   | j j|ƒ d| _dS )aY  
        Set the marker fill style.

        Parameters
        ----------
        fs : {'full', 'left', 'right', 'bottom', 'top', 'none'}
            Possible values:

            - 'full': Fill the whole marker with the *markerfacecolor*.
            - 'left', 'right', 'bottom', 'top': Fill the marker half at
              the given side with the *markerfacecolor*. The other
              half of the marker is filled with *markerfacecoloralt*.
            - 'none': No filling.

            For examples see
            :doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`.
        TN)r­   Úset_fillstyleÚstale)r’   Úfsr2   r2   r3   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-coordinate-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ì   )r’   Zeveryr2   r2   r3   r±   &  s    0
zLine2D.set_markeveryc             C   s   | j S )zr
        Return the markevery setting for marker subsampling.

        See also `~.Line2D.set_markevery`.
        )r®   )r’   r2   r2   r3   Úget_markeveryZ  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¿   )r’   Úpr2   r2   r3   Ú
set_pickerb  s    zLine2D.set_pickerc             C   s^   t ddgddggƒ}| jƒ j}|j|| jƒ ƒdd� | jrZ| jd | jj d }|j	|ƒ}|S )Nr   T)rÐ   g      R@g      à?)
r   Úget_transformrT   Úupdate_from_data_xyÚ
get_xydatar­   r¯   rÙ   rÜ   Úpadded)r’   ÚrendererÚbboxZtrans_data_to_xyrr   r2   r2   r3   Úget_window_extentp  s    

zLine2D.get_window_extentc             C   sV   t jj| |ƒ |d k	rR|jd k	r4|jjjd| jƒ| _|jd k	rR|jjjd| jƒ| _	d S )NÚunits)
r   ÚaxesÚfsetÚxaxisÚ	callbacksÚconnectÚrecache_alwaysZ_xcidÚyaxisZ_ycid)r’   Úaxr2   r2   r3   rù   {  s    




zLine2D.axesc             G   s8   t |ƒdkr|\\}}n|\}}| j|ƒ | j|ƒ dS )z|
        Set the x and y data.

        Parameters
        ----------
        *args : (2, N) array or two 1D arrays
        r   N)r<   Ú	set_xdataÚ	set_ydata)r’   Úargsr6   rC   r2   r2   r3   rÉ   ˆ  s
    
zLine2D.set_datac             C   s   | j dd� d S )NT)Úalways)rÕ   )r’   r2   r2   r3   rþ   ˜  s    zLine2D.recache_alwaysFc       
      C   sŠ  |s
| j r$| j| jƒ}t|ƒjƒ }n| j}|s4| jrN| j| jƒ}t|ƒjƒ }n| j	}t
jt
j||ƒƒjtƒ| _| jj\| _| _	d| _| joÊt|ƒdkoÊ| j|ƒoÊ| jjdkoÊ| jjƒ dkoÊ| jd koÊ| jƒ �r2d| _t
j|ƒ}|jƒ �r*| jjƒ | _t
jt|ƒƒ}t
j|| ||  | j|  ƒ| j|< n| j| _| jd k	�rH| jj }nd}t!| j" | jjŽ }	t#t
j$|	ƒj|d�| _d | _%d| _ d| _d S )NFiè  ZrectilinearÚlinearTr   )Ú_interpolation_steps)&rÃ   Úconvert_xunitsrÁ   r   r?   rŽ   rÄ   Úconvert_yunitsrÂ   r�   r=   Úcolumn_stackÚbroadcast_arraysÚastypeÚfloatrÅ   ÚTrÇ   rù   r<   Ú
_is_sortedÚnameZ
get_xscaler®   Úget_clip_onÚisnanÚanyÚcopyrÈ   rZ   Úinterpr   r  r   r¢   r   rÀ   rÆ   )
r’   r  Zxconvr6   ZyconvrC   ZnanmaskÚindicesZinterpolation_stepsrã   r2   r2   r3   rÕ   ›  sB    








zLine2D.recachec             C   sZ   |dk	r@t | j | j|dd…f jŽ }ttj|ƒj| jjd�}n| j}t	|| j
ƒ ƒ| _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   r=   rÀ   r   r  r   rñ   rÆ   )r’   Úsubslicerã   r   r2   r2   r3   Ú_transform_pathÅ  s    zLine2D._transform_pathc             C   s   | j dkr| jƒ  | j S )zk
        Return the :class:`~matplotlib.transforms.TransformedPath` instance
        of this line.
        N)rÆ   r  )r’   r2   r2   r3   rÖ   Ô  s    
zLine2D._get_transformed_pathc             C   s"   t j| |ƒ 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ì   )r’   Útr2   r2   r3   r  Ý  s    zLine2D.set_transformc             C   s
   t j|ƒS )z.Return whether x is sorted in ascending order.)r   Ú	is_sorted)r’   r6   r2   r2   r3   r  ê  s    zLine2D._is_sortedc             C   sJ  | j ƒ sd S | js| jr | jƒ  d| _| jrˆ| jrˆ| jjƒ \}}| jj	|dƒ}| jj	|dƒ}t
t|d dƒ|d ƒ}|j| _| j|ƒ nd }| jƒ r®ddlm} || jƒ |ƒ}|jd| jƒ ƒ | j| j dk�rÀ| jƒ jƒ \}}	t|jƒ�rÀ|jƒ }
| j|
ƒ tj| j| jƒ}|
j|dd	� |
j | j!ƒ |
j"| j#ƒ | j$ƒ �rL| j%}| j&}n| j'}| j(}|
j)|ƒ |
j*|ƒ |
j+| j,ƒ ƒ | j-ƒ d k	�r–|
j.| j-ƒ Ž  |
j/| j0| j1ƒ |j2|
||	j3ƒ ƒ |
j4ƒ  | j5�r6| j6dk�r6|jƒ }
| j|
ƒ |
j"| j7ƒ |
j | j!ƒ tj| j8ƒ | jƒ}tj| j9ƒ | jƒ}tj| j9dd
�| jƒ}t:j;| j<dƒ�rrt:j=| j>ƒ dƒ �rr|d d… |d f }|
j|dd	� | j-ƒ d k	�r¶| j-ƒ \}}}|
j.|d |d d| ƒ | j5}| j?ƒ dk�r
t:j@| dd d��( | jƒ  | j|ƒ | jƒ jAƒ \}}	W d Q R X n| jƒ jAƒ \}}	t|jƒ�r.| jBƒ }|d k	�rLtC|||	| jjDƒ}n|}|jEƒ }tF|tGƒ�rt|jH| j6ƒ|k}|
j+|ƒ |
j)|jIƒ ƒ |
j*|jJƒ ƒ |jKƒ }|jLƒ }|jH| j6ƒ}t:j;|jMƒ dƒ�rÔ|
j"dƒ n
|jN|ƒ}|jO|
||||	j3ƒ |ƒ |jPƒ }|�r.|jQƒ }|jN|ƒ}|jO|
||||	j3ƒ |ƒ |
j4ƒ  |jRdƒ d| _Sd S )Nr   ÚleftÚrightr   )ÚPathEffectRendererZline2dr~   T)ZisRGBA)ÚaltÚautor”   r‹   r:   rƒ   )r¢   rÆ   rŒ   F)TÚget_visiblerÄ   rÃ   rÕ   r¾   rÇ   rù   Z
get_xboundrÈ   ÚsearchsortedrS   Úmaxre   r  Úget_path_effectsÚmatplotlib.patheffectsr  Ú
open_groupÚget_gidÚ_lineStylesrÞ   rÖ   r×   r<   rR   Únew_gcÚ_set_gc_clipÚmcolorsÚto_rgbar«   Ú_alphaÚset_foregroundr²   r°   r¨   r£   Ú	is_dashedr™   rš   rœ   r›   Úset_joinstyleÚset_capstyleÚset_snapÚget_snapÚget_sketch_paramsÚset_sketch_paramsÚ
set_dashesr¥   r¤   Z	draw_pathÚfrozenÚrestorer­   r¯   rµ   Úget_markeredgecolorÚ_get_markerfacecolorr   Ú
_str_equalr´   Ú_str_lower_equalÚget_markerfacecolorÚget_drawstyleÚ_setattr_cmÚ!get_transformed_points_and_affinerî   rj   Z	transAxesZget_snap_thresholdr'   r   Zpoints_to_pixelsÚget_joinstyleÚget_capstyleÚget_pathrñ   Ú
get_markerrh   Údraw_markersZget_alt_pathZget_alt_transformÚclose_grouprì   )r’   rõ   Úx0Úx1Úi0Úi1r  r  rb   rc   ÚgcZlc_rgbaZcapr�   Zec_rgbaZfc_rgbaZ
fcalt_rgbarh   ÚlengthÚ
randomnessrÌ   ra   Z
subsampledÚsnapZmarker_pathZmarker_transÚwZalt_marker_pathZalt_marker_transr2   r2   r3   Údrawï  sÂ    











zLine2D.drawc             C   s   | j S )z-Return whether antialiased rendering is used.)r°   )r’   r2   r2   r3   Úget_antialiasedt  s    zLine2D.get_antialiasedc             C   s   | j S )zP
        Return the line color.

        See also `~.Line2D.set_color`.
        )r«   )r’   r2   r2   r3   Ú	get_colorx  s    zLine2D.get_colorc             C   s   | j S )zS
        Return the drawstyle.

        See also `~.Line2D.set_drawstyle`.
        )r¢   )r’   r2   r2   r3   r=  €  s    zLine2D.get_drawstylec             C   s   | j S )zS
        Return the linestyle.

        See also `~.Line2D.set_linestyle`.
        )rÞ   )r’   r2   r2   r3   Úget_linestyleˆ  s    zLine2D.get_linestylec             C   s   | j S )z]
        Return the linewidth in points.

        See also `~.Line2D.set_linewidth`.
        )r£   )r’   r2   r2   r3   Úget_linewidth�  s    zLine2D.get_linewidthc             C   s
   | j jƒ S )zR
        Return the line marker.

        See also `~.Line2D.set_marker`.
        )r­   rC  )r’   r2   r2   r3   rC  ˜  s    zLine2D.get_markerc             C   sV   | j }tj|dƒrNtd rH| jjƒ dkr.| jS | jjƒ rH| jƒ dkrHdS | jS |S dS )	za
        Return the marker edge color.

        See also `~.Line2D.set_markeredgecolor`.
        r  z_internal.classic_modeÚ.rŒ   r”   ÚkN)rT  rŒ   )	r´   r   r:  r
   r­   rC  r«   Z	is_filledrê   )r’   ro   r2   r2   r3   r8     s    zLine2D.get_markeredgecolorc             C   s   | j S )zk
        Return the marker edge width in points.

        See also `~.Line2D.set_markeredgewidth`.
        )rµ   )r’   r2   r2   r3   Úget_markeredgewidth±  s    zLine2D.get_markeredgewidthc             C   s<   |r
| j n| j}tj|dƒr4| jƒ dkr,dS | jS n|S d S )Nr  r”   )r·   r¶   r   r;  rê   r«   )r’   r  Úfcr2   r2   r3   r9  ¹  s    zLine2D._get_markerfacecolorc             C   s   | j dd�S )za
        Return the marker face color.

        See also `~.Line2D.set_markerfacecolor`.
        F)r  )r9  )r’   r2   r2   r3   r<  Ã  s    zLine2D.get_markerfacecolorc             C   s   | j dd�S )zn
        Return the alternate marker face color.

        See also `~.Line2D.set_markerfacecoloralt`.
        T)r  )r9  )r’   r2   r2   r3   Úget_markerfacecoloraltË  s    zLine2D.get_markerfacecoloraltc             C   s   | j S )z`
        Return the marker size in points.

        See also `~.Line2D.set_markersize`.
        )r¯   )r’   r2   r2   r3   Ú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)r’   rZ  r2   r2   r3   Úget_dataÛ  s    zLine2D.get_datac             C   s   |r
| j S | jr| jƒ  | jS )z|
        Return the xdata.

        If *orig* is *True*, return the original data, else the
        processed data.
        )rÁ   rÃ   rÕ   rŽ   )r’   rZ  r2   r2   r3   r[  ã  s
    zLine2D.get_xdatac             C   s   |r
| j S | jr| jƒ  | jS )z|
        Return the ydata.

        If *orig* is *True*, return the original data, else the
        processed data.
        )rÂ   rÄ   rÕ   r�   )r’   rZ  r2   r2   r3   r\  ð  s
    zLine2D.get_ydatac             C   s   | j s| jr| jƒ  | jS )ze
        Return the :class:`~matplotlib.path.Path` object associated
        with this line.
        )rÄ   rÃ   rÕ   r   )r’   r2   r2   r3   rB  ý  s    zLine2D.get_pathc             C   s   | j s| jr| jƒ  | jS )z<
        Return the *xy* data as a Nx2 numpy array.
        )rÄ   rÃ   rÕ   rÅ   )r’   r2   r2   r3   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ì   )r’   Úbr2   r2   r3   r²     s    
zLine2D.set_antialiasedc             C   s   || _ d| _dS )zi
        Set the color of the line.

        Parameters
        ----------
        color : color
        TN)r«   rì   )r’   rt   r2   r2   r3   r¬     s    zLine2D.set_colorc             C   s<   |dkrd}t j| j|d� | j|kr2d| _d| _|| _dS )aÔ  
        Set the drawstyle of the plot.

        The drawstyle determines how the points are connected.

        Parameters
        ----------
        drawstyle : {'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
            For 'default', the points are connected with straight lines.

            The steps variants connect the points with step-like lines,
            i.e. horizontal lines with vertical steps. They differ in the
            location of the step:

            - 'steps-pre': The step is at the beginning of the line segment,
              i.e. the line will be at the y-value of point to the right.
            - 'steps-mid': The step is halfway between the points.
            - 'steps-post: The step is at the end of the line segment,
              i.e. the line will be at the y-value of the point to the left.
            - 'steps' is equal to 'steps-pre' and is maintained for
              backward-compatibility.

        Nrƒ   )ru   T)r   Ú_check_in_listÚ
drawStylesr¢   rì   rÃ   )r’   ru   r2   r2   r3   rª   %  s    
zLine2D.set_drawstylec             C   s<   t |ƒ}| j|krd| _|| _t| j| j| jƒ\| _| _dS )zh
        Set the line width in points.

        Parameters
        ----------
        w : float
        TN)r  r£   rì   r9   r§   r¦   r¥   r¤   )r’   rN  r2   r2   r3   r¨   G  s    
zLine2D.set_linewidthc             C   sH   x>| j D ]4}|j|ƒrtjddd� ||t|ƒd… p8d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.
        z3.1a  Passing the drawstyle with the linestyle as a single string is deprecated since Matplotlib %(since)s and support will be removed %(removal)s; please pass the drawstyle separately using the drawstyle keyword argument to Line2D or set_drawstyle() method (or ds/set_ds()).)ÚmessageNr   )ÚdrawStyleKeysrß   r   Úwarn_deprecatedr<   )r’   rn   rm   r2   r2   r3   r˜   X  s    

z!Line2D._split_drawstyle_linestylec             C   s˜   t |tƒrd| j|ƒ\}}|dk	r*| j|ƒ |dkr6d}tj| jt•|d� || jkr\t| }|| _nd| _t	|ƒ\| _
| _t| j
| j| jƒ\| _| _dS )	a›  
        Set the linestyle of the line.

        Parameters
        ----------
        ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
            Possible values:

            - A string:

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

              Optionally, the string may be preceded by a drawstyle, e.g.
              ``'steps--'``. See :meth:`set_drawstyle` for details.

            - 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. See also :meth:`set_dashes`.
        Nr�   r‚   r”   r#   )rn   z--)r�   r‚   r”   )r'   r(   r˜   rª   r   r_  r'  r   rÞ   r4   r§   r¦   r9   r£   r¥   r¤   )r’   rn   rm   r2   r2   r3   r©   y  s     


zLine2D.set_linestylec             C   s   | j 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ì   )r’   rÌ   r2   r2   r3   rd  ®  s    zLine2D.set_markerc             C   s6   |dkrd}| j dks&tj| j |kƒr,d| _|| _ dS )zf
        Set the marker edge color.

        Parameters
        ----------
        ec : color
        Nr  T)r´   r=   r  rì   )r’   Úecr2   r2   r3   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ì   )r’   Úewr2   r2   r3   r»   Ë  s
    
zLine2D.set_markeredgewidthc             C   s,   |dkrd}t j| j|kƒr"d| _|| _dS )zf
        Set the marker face color.

        Parameters
        ----------
        fc : color
        Nr  T)r=   r  r¶   rì   )r’   rW  r2   r2   r3   r¸   Ù  s
    zLine2D.set_markerfacecolorc             C   s,   |dkrd}t j| j|kƒr"d| _|| _dS )zp
        Set the alternate marker face color.

        Parameters
        ----------
        fc : color
        Nr  T)r=   r  r·   rì   )r’   rW  r2   r2   r3   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ì   )r’   Úszr2   r2   r3   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ì   )r’   r6   r2   r2   r3   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ì   )r’   rC   r2   r2   r3   r    s    zLine2D.set_ydatac             C   s2   |dkst |ƒdkr | jdƒ n| jd|fƒ dS )aõ  
        Set the dash sequence.

        The dash sequence is a sequence of floats of even length describing
        the length of dashes and spaces in points.

        For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point
        dashes separated by 2 point spaces.

        Parameters
        ----------
        seq : sequence of floats (on/off ink in points) or (None, None)
            If *seq* is empty or ``(None, None)``, the linestyle will be set
            to solid.
        Nr   r   )NN)r<   r©   )r’   Úseqr2   r2   r3   r5    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| _|j| _t|jjƒ |jjƒ ƒ| _|j| _dS )z#Copy properties from other to self.N)r   Úupdate_fromrÞ   r£   r«   r¯   r¶   r·   r´   rµ   r¤   r¦   r¥   r§   r™   rš   rœ   r›   r   r­   rC  rê   r¢   )r’   Úotherr2   r2   r3   ri  /  s*    
zLine2D.update_fromc             C   s2   |j ƒ }tj| j|d� | j|kr(d| _|| _dS )zÔ
        Set the join style for dashed lines.

        Parameters
        ----------
        s : {'miter', 'round', 'bevel'}
            For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
        )ÚsTN)Úlowerr   r_  Ú	validJoinrš   rì   )r’   rk  r2   r2   r3   rž   H  s
    	
zLine2D.set_dash_joinstylec             C   s2   |j ƒ }tj| j|d� | j|kr(d| _|| _dS )zÓ
        Set the join style for solid lines.

        Parameters
        ----------
        s : {'miter', 'round', 'bevel'}
            For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
        )rk  TN)rl  r   r_  rm  r›   rì   )r’   rk  r2   r2   r3   r    W  s
    	
zLine2D.set_solid_joinstylec             C   s   | j S )zj
        Return the join style for dashed lines.

        See also `~.Line2D.set_dash_joinstyle`.
        )rš   )r’   r2   r2   r3   Úget_dash_joinstylef  s    zLine2D.get_dash_joinstylec             C   s   | j S )zj
        Return the join style for solid lines.

        See also `~.Line2D.set_solid_joinstyle`.
        )r›   )r’   r2   r2   r3   Úget_solid_joinstylen  s    zLine2D.get_solid_joinstylec             C   s2   |j ƒ }tj| j|d� | j|kr(d| _|| _dS )zˆ
        Set the cap style for dashed lines.

        Parameters
        ----------
        s : {'butt', 'round', 'projecting'}
        )rk  TN)rl  r   r_  ÚvalidCapr™   rì   )r’   rk  r2   r2   r3   r�   v  s
    
zLine2D.set_dash_capstylec             C   s2   |j ƒ }tj| j|d� | j|kr(d| _|| _dS )z‡
        Set the cap style for solid lines.

        Parameters
        ----------
        s : {'butt', 'round', 'projecting'}
        )rk  TN)rl  r   r_  rp  rœ   rì   )r’   rk  r2   r2   r3   rŸ   „  s
    
zLine2D.set_solid_capstylec             C   s   | j S )zh
        Return the cap style for dashed lines.

        See also `~.Line2D.set_dash_capstyle`.
        )r™   )r’   r2   r2   r3   Úget_dash_capstyle’  s    zLine2D.get_dash_capstylec             C   s   | j S )zh
        Return the cap style for solid lines.

        See also `~.Line2D.set_solid_capstyle`.
        )rœ   )r’   r2   r2   r3   Úget_solid_capstyleš  s    zLine2D.get_solid_capstylec             C   s
   | j dkS )zi
        Return whether line has a dashed linestyle.

        See also `~.Line2D.set_linestyle`.
        ú--ú-.r€   )rs  rt  r€   )rÞ   )r’   r2   r2   r3   r.  ¢  s    zLine2D.is_dashed)r…   r†   r‡   )rˆ   r†   r‰   )NNNNNNNNr”   NNNNNNr•   NN)F)N)F)T)T)T)YÚ__name__Ú
__module__Ú__qualname__Ú__doc__Ú
lineStylesr'  Z_drawStyles_lZ_drawStyles_sr`  rb  r   ÚmarkersZfilled_markersÚ
fillstylesÚ
fillStylesÚzorderrp  rm  r“   r–   r   Ú
deprecatedÚpropertyrÏ   ræ   rç   ré   rê   rë   r±   rî   rð   r÷   r   rù   ÚsetterrÉ   rþ   rÕ   r  rÖ   r  r  r   rO  rP  rQ  r=  rR  rS  rC  r8  rV  r9  r<  rX  rY  r]  r[  r\  rB  ró   r²   r¬   rª   r¨   r˜   r©   r	   Údedent_interpdrd  rº   r»   r¸   r¹   r³   r  r  r5  ri  rž   r    rn  ro  r�   rŸ   rq  rr  r.  r2   r2   r2   r3   r}   Ì   sÐ                    
 H4
*
	 




	"!5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ƒ‚|jƒ dkr&tdƒ‚|j | _ || _| 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 lineÚ
pick_event)rù   r—   Ú
get_pickerÚlinerÙ   ÚcanvasÚmpl_connectÚonpickÚcidÚsetrÒ   )r’   r…  r2   r2   r3   r–   Ê  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.
        Nr2   )r’   rÒ   ÚxsÚysr2   r2   r3   Úprocess_selectedß  s    zVertexSelector.process_selectedc             C   sV   |j | jk	rdS |  jt|jƒN  _t| jƒ}| jjƒ \}}| j||| || ƒ dS )z<When the line is picked, update the set of selected indices.N)r   r…  rÒ   rŠ  Úsortedr]  r�  )r’   ÚeventrÒ   rÊ   rË   r2   r2   r3   rˆ  é  s    
zVertexSelector.onpickN)ru  rv  rw  rx  r–   r�  rˆ  r2   r2   r2   r3   r‚  «  s   
r‚  )Z_Line2D_docstr)?rx  Únumbersr   r   r   ÚloggingÚnumpyr=   r‚   r   r   r   r*  r	   r
   r   r   r   r   r   r   rz  r   râ   r   Ú
transformsr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   Ú	getLoggerru  rÚ   r4   r9   rN   rj   Ú_define_aliasesr}   Úobjectr‚  r'  ry  ZlineMarkersr`  r{  r|  Úinterpdr¼   Úkwdocr�  r–   r2   r2   r2   r3   Ú<module>   sX   8
%^         \H