3
ƽh]                 @   s  d Z ddlmZmZmZ ddl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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- ej.e/Z0dd Z1dd Z2dd Z3dd Z4ej5d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Z6G d"d# d#e6Z7G d$d% d%Z8e6j9Z:ejZ;e6j<Z<ej=Z>ej?j@ejAe6d& ejBe6jC dS )'zU
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)Affine2DBboxBboxTransformFromBboxTransformTo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}d}n^| dkrHd}ttdj|  }n>t | trv| \}}|dkrtjd	d
d d}nt	dt|  |dk	rt
|}|r||; }||fS )z"Convert linestyle to dash pattern.solidNoner   Ndasheddashdotdottedzlines.{}_patternz3.3zPassing the dash offset as None is deprecated since %(since)s and support for it will be removed %(removal)s; pass it as zero instead.)messagezUnrecognized linestyle: %s)r%   r&   )r'   r(   r)   )
isinstancestrr   gettupler
   formatr   warn_deprecated
ValueErrorsum)styleoffsetdashesZdsum r6   6/tmp/pip-build-7iwl8md4/matplotlib/matplotlib/lines.py_get_dash_pattern!   s(    


r8   c                s>   t d s| |fS |   }|d k	r2 fdd|D nd }||fS )Nzlines.scale_dashesc                s    g | ]}|d k	r|  nd qS )Nr6   ).0x)lwr6   r7   
<listcomp>G   s    z!_scale_dashes.<locals>.<listcomp>)r
   )r4   r5   r;   Zscaled_offsetZscaled_dashesr6   )r;   r7   _scale_dashesC   s
    r=   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ravelZconcatenate)Zcxcyr:   yZradiusresZxryrdxdyZLnorm_squ
candidatesZ
point_hitsZpxpyZ	line_hitsZpointslinesr6   r6   r7   segment_hitsL   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rt|tstdj| t	|t
|d| ||t
|d|S t|trt|tst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|
j j }
|jddgd
d
gg\\}}\}}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nt| t
r t	||  ||| S tj| r~yt	||  ||| S  ttfk
rz } ztd| d|W Y dd}~X 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 )z@Helper function to cope with `codes` being an ndarray or `None`.Nr6   )Zin_vZslcr6   r6   r7   _slice_or_none|   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   )Z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@   r1   r/   r   slice	transformrA   emptyhypotTZcumsumarangeabsZnewaxisZargminuniqueiterable
IndexError)	markeverytpathaffineZax_transformrP   ZvertsrO   startstepZdisp_coordsdeltax0Zy0x1y1scaleZmarker_deltaZindserrr6   r6   r7   _mark_every_pathq   s^    	





8"*
rg   ZaacZdslsr;   mecZmewZ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dZdZdd ZdddZdd Zdd Zdd  Zeee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/d0 Z"d1d2 Z#dd4d5Z$dd6d7Z%d8d9 Z&d:d; Z'd<d= Z(e)d>d? Z*d@dA Z+dBdC Z,dDdE Z-dFdG Z.dHdI Z/dJdK Z0dLdM Z1dNdO Z2ddPdQZ3dRdS Z4dTdU Z5dVdW Z6ddYdZZ7dd[d\Z8dd]d^Z9d_d` Z:dadb Z;dcdd Z<dedf Z=dgdh Z>didj Z?dkdl Z@eAjBdmdn ZCdodp ZDdqdr ZEdsdt ZFdudv ZGdwdx ZHdydz ZId{d| ZJd}d~ ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUd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?   )Z_label_xr@   _yjoinmapr/   )selfr6   r6   r7   __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rtd	 }|dkrtd
 }|dkrtd }|dkrtd }|dkrtd }|dkrtd }|dkrtd }|dkrd}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*| || _+d| _,tj-g | _.tj-g | _/d| _0d| _1d| _2d| _3d| _4d| _5d| _6d| _7d| _8| j9|| dS )a  
        Create a `.Line2D` instance with *x* and *y* data in sequences of
        *xdata*, *ydata*.

        Additional keyword arguments are `.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_joinstyler|   r   TF):r   __init__rA   rZ   RuntimeErrorr
   _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_markeredgewidthupdate
pickradius
ind_offsetasarray_xorig_yorig	_invalidx	_invalidyr   r   _xyr   _transformed_path	_subslice	_x_filledset_data)r   xdataydatarp   ro   rm   markerru   rr   rq   rs   rt   Z	fillstylerl   Zdash_capstyleZsolid_capstyleZdash_joinstyleZsolid_joinstyler   rn   r\   kwargsr6   r6   r7   r     s    "


















zLine2D.__init__c             C   sV  | j |\}}|dk	r||fS | js*| jr2| j  t| jdkrHdi fS | j }|j \}}|j|}|j	}|dddf }|dddf }	| j
dkrt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r,|d
 }W dQ R X || j7 }t|dkt|dfS )a
  
        Test whether *mouseevent* occurred on the line.

        An event is deemed to have occurred "on" the line if it is less
        than ``self.pickradius`` (default: 5 points) away from it.  Use
        `~.Line2D.get_pickradius` or `~.Line2D.set_pickradius` to get or set
        the pick radius.

        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
        Nr   Fr   z,no figure set when check if mouse is on lineg      R@ignore)allr&   r>   r}   )ind)r&   N)Z_default_containsr   r   recacher@   r   _get_transformed_pathget_transformed_path_and_affineZtransform_pathrQ   figure_logwarningr   dpirA   Zerrstate
_linestylerB   r:   rE   rN   r   
startswithr   dict)r   Z
mouseeventZinsideinfoZtransformed_pathpathr^   xyZxtZytZpixelsr   r6   r6   r7   contains  s6    



zLine2D.containsc             C   s   | j S )zo
        Return the pick radius used for containment tests.

        See `.contains` for more details.
        )_pickradius)r   r6   r6   r7   get_pickradius  s    zLine2D.get_pickradiusc             C   s&   t |t s|dk rtd|| _dS )z
        Set the pick radius used for containment tests.

        See `.contains` for more details.

        Parameters
        ----------
        d : float
            Pick radius, in points.
        r   z pick radius should be a distanceN)r+   r   r1   r   )r   dr6   r6   r7   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   r6   r6   r7   r     s    zLine2D.get_fillstylec             C   s   | j j| d| _dS )a%  
        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 :ref:`marker_fill_styles`.
        TN)r   set_fillstylestale)r   fsr6   r6   r7   r     s    zLine2D.set_fillstylec             C   s   || _ 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) or List[bool]
            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=[True, False, True], positions that are True 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.

            For examples see
            :doc:`/gallery/lines_bars_and_markers/markevery_demo`.

        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everyr6   r6   r7   r     s    6zLine2D.set_markeveryc             C   s   | j S )zr
        Return the markevery setting for marker subsampling.

        See also `~.Line2D.set_markevery`.
        )r   )r   r6   r6   r7   get_markeveryL  s    zLine2D.get_markeveryc             C   s4   t |tr*t |t r*tjddd || _|| _d S )Nz3.3zSetting the line's pick radius via set_picker is deprecated since %(since)s and will be removed %(removal)s; use set_pickradius instead.)r*   )r+   r   boolr   r0   r   Z_picker)r   pr6   r6   r7   
set_pickerT  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_transformrS   Zupdate_from_data_xy
get_xydatar   r   r   r   Zpadded)r   rendererZbboxZtrans_data_to_xyrk   r6   r6   r7   get_window_extent_  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 )NZunits)
r   axesfsetZxaxis	callbacksconnectrecache_alwaysZ_xcidZyaxisZ_ycid)r   axr6   r6   r7   r   j  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   argsr:   rE   r6   r6   r7   r   w  s
    
zLine2D.set_datac             C   s   | j dd d S )NT)always)r   )r   r6   r6   r7   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ot|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rectilinearZlinearTr   )_interpolation_steps)&r   Zconvert_xunitsr   r   rC   r   r   Zconvert_yunitsr   r   rA   Zcolumn_stackZbroadcast_arraysZastypefloatr   rV   r   r   r@   
_is_sortednameZ
get_xscaler   Zget_clip_onisnananycopyr   rW   Zinterpr   r   r   r   r   r   r   )
r   r   Zxconvr:   ZyconvrE   ZnanmaskindicesZinterpolation_stepsr   r6   r6   r7   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   rV   r   rA   r   r   r   r   r   r   )r   subslicer   r   r6   r6   r7   _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   r6   r6   r7   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   tr6   r6   r7   r     s    zLine2D.set_transformc             C   s
   t j|S )z.Return whether x is sorted in ascending order.)r   Z	is_sorted)r   r:   r6   r6   r7   r     s    zLine2D._is_sortedc             C   sf  | 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 rddlm} || j |}|jd| j  | j| j dkr| j j \}}	t|jr|j }
| j|
 |
j| j  tj| j| j }|
j!|dd	 |
j"| j# |
j$| j% | j& rZ| j'}| j(}n| j)}| j*}|
j+| |
j,| |
j-| j.  | j/ d k	r|
j0| j/   |
j1| j2| j3 |j4|
||	j5  |
j6  | j7rR| j8dkrR|j }
| j|
 |
j| j  |
j$| j9 |
j"| j# tj| j: | j }tj| j; | j }tj| j;dd
| j }t<j=| j>drt<j?| j@ d r|d d |d f }|
j!|dd	 | j/ d k	r| j/ \}}}|
j0|d |d d|  | j7}| jA dkr&t<jB| dd d( | j  | j| | j jC \}}	W d Q R X n| j jC \}}	t|jrJ| jD }|d k	rhtE|||	| jjF}n|}|jG }tH|tIr|jJ| j8|k}|
j-| |
j+|jK  |
j,|jL  |jM }|jN }|jJ| j8}t<j=|jO dr|
j$d n
|jP|}|jQ|
||||	j5 | |jR }|rJ|jS }|jP|}|jQ|
||||	j5 | |
j6  |jTd d| _Ud S )Nr   leftrightr   )PathEffectRendererZline2drw   T)ZisRGBA)altautor   r   r>   r|   )r   r   r   F)VZget_visibler   r   r   r   r   r   Z
get_xboundr   ZsearchsortedrR   maxr_   r   Zget_path_effectsZmatplotlib.patheffectsr   Z
open_groupZget_gid_lineStylesr   r   r   r@   rQ   Znew_gcZ_set_gc_clipZset_urlget_urlmcolorsZto_rgbar   Z_alphaZset_foregroundr   r   r   r   	is_dashedr   r   r   r   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_cmZ!get_transformed_points_and_affiner   rg   	transAxesZget_snap_thresholdr+   r   Zpoints_to_pixelsZget_joinstyleZget_capstyleget_pathr   
get_markerre   Zdraw_markersZget_alt_pathZget_alt_transformZclose_groupr   )r   r   rb   rc   Zi0i1r   r   r]   r^   gcZlc_rgbacapr   Zec_rgbaZfc_rgbaZ
fcalt_rgbare   lengthZ
randomnessr   r\   Z
subsampledZsnapZmarker_pathZmarker_transwZalt_marker_pathZalt_marker_transr6   r6   r7   draw  s    











zLine2D.drawc             C   s   | j S )z-Return whether antialiased rendering is used.)r   )r   r6   r6   r7   get_antialiasede  s    zLine2D.get_antialiasedc             C   s   | j S )zP
        Return the line color.

        See also `~.Line2D.set_color`.
        )r   )r   r6   r6   r7   	get_colori  s    zLine2D.get_colorc             C   s   | j S )zS
        Return the drawstyle.

        See also `~.Line2D.set_drawstyle`.
        )r   )r   r6   r6   r7   r  q  s    zLine2D.get_drawstylec             C   s   | j S )zS
        Return the linestyle.

        See also `~.Line2D.set_linestyle`.
        )r   )r   r6   r6   r7   get_linestyley  s    zLine2D.get_linestylec             C   s   | j S )z]
        Return the linewidth in points.

        See also `~.Line2D.set_linewidth`.
        )r   )r   r6   r6   r7   get_linewidth  s    zLine2D.get_linewidthc             C   s
   | j j S )zR
        Return the line marker.

        See also `~.Line2D.set_marker`.
        )r   r  )r   r6   r6   r7   r    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)r  r   )	r   r   r  r
   r   r  r   Z	is_filledr   )r   rj   r6   r6   r7   r    s    zLine2D.get_markeredgecolorc             C   s   | j S )zk
        Return the marker edge width in points.

        See also `~.Line2D.set_markeredgewidth`.
        )r   )r   r6   r6   r7   get_markeredgewidth  s    zLine2D.get_markeredgewidthc             C   s:   | j  dkrdS |r| jn| j}tj|dr2| jS |S d S )Nr   r   )r   r   r   r   r	  r   )r   r   fcr6   r6   r7   r    s    zLine2D._get_markerfacecolorc             C   s   | j ddS )za
        Return the marker face color.

        See also `~.Line2D.set_markerfacecolor`.
        F)r   )r  )r   r6   r6   r7   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   )r  )r   r6   r6   r7   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   r6   r6   r7   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   r  r6   r6   r7   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   r  r6   r6   r7   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   r  r6   r6   r7   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   r6   r6   r7   r    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   r6   r6   r7   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   br6   r6   r7   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   rm   r6   r6   r7   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.

            For examples see :doc:`/gallery/lines_bars_and_markers/step_demo`.
        Nr|   )rn   T)r   _check_in_list
drawStylesr   r   r   )r   rn   r6   r6   r7   r     s    
zLine2D.set_drawstylec             C   s<   t |}| j|krd| _|| _t| j| j| j\| _| _dS )z
        Set the line width in points.

        Parameters
        ----------
        w : float
            Line width, in points.
        TN)r   r   r   r=   r   r   r   r   )r   r  r6   r6   r7   r   8  s    	
zLine2D.set_linewidthc             C   sx   t |trD|dkrd}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
              ===============================   =================

            - 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`.

            For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
        rz   r{   r   r&   )ri   z--N)rz   r{   r   )r+   r,   r   r$  r   r   r   r8   r   r   r=   r   r   r   )r   ri   r6   r6   r7   r   J  s    

zLine2D.set_linestylec             C   s   | j j| d| _dS )z
        Set the line marker.

        Parameters
        ----------
        marker : marker style string, `~.path.Path` or `~.markers.MarkerStyle`
            See `~matplotlib.markers` for full description of possible
            arguments.
        TN)r   
set_markerr   )r   r   r6   r6   r7   r&  z  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   rA   r   r   )r   Zecr6   r6   r7   r     s    
zLine2D.set_markeredgecolorc             C   s*   |dkrt d }| j|kr d| _|| _dS )z
        Set the marker edge width in points.

        Parameters
        ----------
        ew : float
             Marker edge width, in points.
        Nzlines.markeredgewidthT)r
   r   r   )r   ewr6   r6   r7   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)rA   r   r   r   )r   r  r6   r6   r7   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)rA   r   r   r   )r   r  r6   r6   r7   r     s
    zLine2D.set_markerfacecoloraltc             C   s"   t |}| j|krd| _|| _dS )z
        Set the marker size in points.

        Parameters
        ----------
        sz : float
             Marker size, in points.
        TN)r   r   r   )r   szr6   r6   r7   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   r:   r6   r6   r7   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   rE   r6   r6   r7   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   rx   )NN)r@   r   )r   seqr6   r6   r7   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| _|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   r  r   r   )r   otherr6   r6   r7   r*    s*    
zLine2D.update_fromc             C   s&   t jj| | 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`.
        TN)mplrcsetupvalidate_joinstyler   r   )r   sr6   r6   r7   r     s    	
zLine2D.set_dash_joinstylec             C   s&   t jj| | 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`.
        TN)r,  r-  r.  r   r   )r   r/  r6   r6   r7   r   $  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   r6   r6   r7   get_dash_joinstyle2  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   r6   r6   r7   get_solid_joinstyle:  s    zLine2D.get_solid_joinstylec             C   s&   t jj| | j|krd| _|| _dS )z
        Set the cap style for dashed lines.

        Parameters
        ----------
        s : {'butt', 'round', 'projecting'}
            For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
        TN)r,  r-  validate_capstyler   r   )r   r/  r6   r6   r7   r   B  s    	
zLine2D.set_dash_capstylec             C   s&   t jj| | j|krd| _|| _dS )z
        Set the cap style for solid lines.

        Parameters
        ----------
        s : {'butt', 'round', 'projecting'}
            For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
        TN)r,  r-  r2  r   r   )r   r/  r6   r6   r7   r   P  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   r6   r6   r7   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   r6   r6   r7   get_solid_capstylef  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`.
        ---.ry   )r5  r6  ry   )r   )r   r6   r6   r7   r  n  s    zLine2D.is_dashed)r~   r   r   )r   r   r   )NNNNNNNNr   NNNNNNr   NN)F)N)F)T)T)T)V__name__
__module____qualname____doc__
lineStylesr   Z_drawStyles_lZ_drawStyles_sr%  ZdrawStyleKeysr   markersZfilled_markers
fillstyles
fillStylesZzorderZvalidCapZ	validJoinr   r   r   r   r   propertyr   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   r   r	   dedent_interpdr&  r   r   r   r   r   r   r   r  r*  r   r   r0  r1  r   r   r3  r4  r  r6   r6   r6   r7   rv      s                    
yF
9
*
	 
	


	#0rv   c                   s(   e Zd ZdZdd Z fddZ  ZS )_AxLinezo
    A helper class that implements `~.Axes.axline`, by recomputing the artist
    transform at draw time.
    c             C   s  | j }|jjt| j  \\}}\}}|| }|| }tj||rtj||rntd| j  d| j	  dt
jdddd| d| | |jdd S tj||rt
jd| ddd| | d|jdd S |jj|j\\}}	\}
}t|||| | |  f|
||
| | |  f||	| | |  |	f||| | |  |fg\}}}}ttt| j  tt||g |j |j S )Nz3Cannot draw a line through two identical points (x=z, y=r   r   r   Zgrid)which)r   Z
transScalerS   zipr"  rA   Zallcloser1   r   r!  r   Zfrom_valuesZget_xaxis_transformZget_yaxis_transformZviewLimsortedr   r   r   ZtransLimitsr  )r   r   rc   rd   Zx2y2rH   rI   ZvxloZvyloZvxhiZvyhi_r_   stopr6   r6   r7   r   }  s(    "$z_AxLine.get_transformc                s   d | _ t j| d S )N)r   superr  )r   r   )	__class__r6   r7   r    s    z_AxLine.draw)r7  r8  r9  r:  r   r  __classcell__r6   r6   )rJ  r7   rB  w  s   rB  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
    `.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 `.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   r   Z
get_pickerliner   ZcanvasZmpl_connectonpickZcidsetr   )r   rM  r6   r6   r7   r     s    
zVertexSelector.__init__c             C   s   dS )a*  
        Default "do nothing" implementation of the
        :meth:`process_selected` method.

        Parameters
        ----------
        ind : list of int
            The indices of the selected vertices.
        xs, ys : array-like
            The coordinates of the selected vertices.
        Nr6   )r   r   xsZysr6   r6   r7   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   rM  r   rO  rE  r"  rQ  )r   eventr   r   r   r6   r6   r7   rN    s    
zVertexSelector.onpickN)r7  r8  r9  r:  r   rQ  rN  r6   r6   r6   r7   rL    s   rL  )Z_Line2D_docstr)Dr:  numbersr   r   r   loggingnumpyrA   Z
matplotlibr,  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"   r#   r$   	getLoggerr7  r   r8   r=   rN   rg   Z_define_aliasesrv   rB  rL  r   r;  ZlineMarkersr%  r=  r>  Zinterpdr   ZkwdocrA  r   r6   r6   r6   r7   <module>   s\   8
"	%W         ,)K