B
    ·ôJdÊ  ã               @   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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 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 0e1¡Z2dd„ Z3dd„ Z4dd„ Z5dd„ Z6ej7e 8d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ƒƒƒZ9G d#d$„ d$e9ƒZ:G d%d&„ d&ƒZ;e9j<Z=ejZ>e9j?Z?ej@ZAdS )'zK
2D lines with support for a variety of line styles, markers, colors, etc.
é    )ÚIntegralÚNumberÚRealNé   )Ú_apiÚartistÚcbookÚcolorsÚ	docstringÚrcParams)ÚArtistÚallow_rasterization)Ú_to_unmasked_float_arrayÚ	ls_mapperÚls_mapper_rÚSTEP_LOOKUP_MAP)ÚMarkerStyle)ÚPath)ÚBboxÚBboxTransformToÚTransformedPath)Ú	JoinStyleÚCapStyle)Ú_path)Ú	CARETLEFTÚ
CARETRIGHTÚCARETUPÚ	CARETDOWNÚCARETLEFTBASEÚCARETRIGHTBASEÚCARETUPBASEÚCARETDOWNBASEÚTICKLEFTÚ	TICKRIGHTÚTICKUPÚTICKDOWNc             C   s¤   t | tƒrt | | ¡} | dkr(d}d}nX| dkrHd}ttd | ¡ ƒ}n8t | tƒrr| \}}|dkr€td| ›ƒ‚ntd| ›ƒ‚|dk	rœt|ƒ}|rœ||; }||fS )z"Convert linestyle to dash pattern.)ZsolidÚNoner   N)ZdashedZdashdotZdottedzlines.{}_patternzUnrecognized linestyle: )	Ú
isinstanceÚstrr   ÚgetÚtupler   ÚformatÚ
ValueErrorÚsum)ÚstyleÚoffsetÚdashesZdsum© r1   úB/var/www/html/venv/lib/python3.7/site-packages/matplotlib/lines.pyÚ_get_dash_pattern   s$    

r3   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 )Nr1   )Ú.0Úx)Úlwr1   r2   ú
<listcomp>A   s    z!_scale_dashes.<locals>.<listcomp>)r   )r/   r0   r6   Zscaled_offsetZscaled_dashesr1   )r6   r2   Ú_scale_dashes=   s
    r8   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›
    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   é   Néÿÿÿÿr   )ÚlenÚnpÚnonzeroÚravelZconcatenate)ZcxÚcyr5   ÚyZradiusÚresZxrÚyrÚdxÚdyZLnorm_sqÚuÚ
candidatesZ
point_hitsZpxÚpyZ	line_hitsZpointsÚlinesr1   r1   r2   Úsegment_hitsF   s     ("  rI   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	 | ¡ƒ‚|dkrä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|
jŽ  ¡ }
|j ddgddgg¡\\}}\}}t || || ¡}t || |
d || ¡}t |
tjdd…f |dd…tjf  ¡}|jdd}t |¡}t	|| |||ƒƒS td| ›dƒ‚nŽt| t
ƒr2t	||  ||| ƒƒS t | ¡ryt	||  ||| ƒƒS  ttfk
rŒ } ztd| ›dƒ|‚W dd}~X 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 )z@Helper function to cope with `codes` being an ndarray or `None`.Nr1   )Zin_vZslcr1   r1   r2   Ú_slice_or_nonev   s    z(_mark_every_path.<locals>._slice_or_noner   g        r9   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={}z]markevery is specified relative to the axes size, but the line does not have a Axes as parentr   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 value)ÚcodesÚverticesr'   r   r   r*   r;   r,   r+   r   ÚsliceÚ	transformr<   ÚemptyÚhypotÚTZcumsumÚ	transAxesÚarangeÚabsZnewaxisZargminÚuniqueÚiterableÚ
IndexError)Ú	markeveryÚtpathÚaffineÚaxrK   ZvertsrJ   ÚstartÚstepZdisp_coordsÚdeltaÚx0Zy0Úx1Úy1ÚscaleZmarker_deltaZindsÚerrr1   r1   r2   Ú_mark_every_pathk   sd    	





8$*
rd   ZaaÚcZdsÚlsr6   Ú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e d¡ejdd„ ƒƒZe d¡ejdd„ ƒƒZdd„ Zd“‡ fd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!d-d.„ Z"d/d0„ Z#d”d2d3„Z$d•d4d5„Z%d6d7„ Z&‡ fd8d9„Z'd:d;„ Z(e)d<d=„ ƒZ*d>d?„ Z+d@dA„ Z,dBdC„ Z-dDdE„ Z.dFdG„ Z/dHdI„ Z0dJdK„ Z1dLdM„ Z2d–dNdO„Z3dPdQ„ Z4dRdS„ Z5dTdU„ Z6d—dWdX„Z7d˜dYdZ„Z8d™d[d\„Z9d]d^„ Z:d_d`„ Z;dadb„ Z<dcdd„ Z=dedf„ Z>dgdh„ Z?didj„ Z@eAjBdkdl„ ƒZCdmdn„ ZDdodp„ ZEdqdr„ ZFdsdt„ ZGdudv„ ZHdwdx„ ZIdydz„ ZJd{d|„ ZKd}d~„ ZL‡ fdd€„ZMeAjBdd‚„ ƒZNeAjBdƒd„„ ƒZOd…d†„ ZPd‡dˆ„ ZQeAjBd‰dŠ„ ƒZReAjBd‹dŒ„ ƒZSddŽ„ ZTdd„ ZUd‘d’„ ZV‡  ZWS )šÚ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Ústepsr9   z3.4c             C   s   t dd„ tD ƒƒS )Nc             s   s   | ]}|j V  qd S )N)Úvalue)r4   Úcsr1   r1   r2   ú	<genexpr>   s    z"Line2D.validCap.<locals>.<genexpr>)r*   r   )Úclsr1   r1   r2   ÚvalidCapý   s    zLine2D.validCapc             C   s   t dd„ tD ƒƒS )Nc             s   s   | ]}|j V  qd S )N)r{   )r4   Újsr1   r1   r2   r}     s    z#Line2D.validJoin.<locals>.<genexpr>)r*   r   )r~   r1   r1   r2   Ú	validJoin  s    zLine2D.validJoinc             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
 tdj| j| jƒ¡ S d S )Nrx   zLine2D(ú)zLine2D()é   z#Line2D((%g,%g),(%g,%g),...,(%g,%g))r   r:   z
Line2D(%s)ú,z({:g},{:g}))Z_labelÚ_xr;   Ú_yÚjoinÚmapr+   )Úselfr1   r1   r2   Ú__str__  s    

zLine2D.__str__NÚnoneé   c                s†  t ƒ  ¡  t |¡stdƒ‚t |¡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Úd}d| _d| _d| _d| _	|  
|¡ |  |¡ |  |¡ |  |¡ d| _d| _|| _d| _d| _d| _d| _|  |¡ |  |¡ |  |¡ d| _|  |¡ t||ƒ| _d| _d| _d| _|  |¡ |   |¡ |  !|¡ d| _"d| _#d| _$d| _%|  &|
¡ |  '|¡ |  (|	¡ |  )|¡ |  *|¡ || _+d| _,t-| j.t/ƒr(t-| j.t0ƒs(| j.| _+t 1g ¡| _2t 1g ¡| _3d| _4d| _5d| _6d| _7d| _8d| _9d| _:d| _;d| _<|  =||¡ dS )a–  
        Create a `.Line2D` instance with *x* and *y* data in sequences of
        *xdata*, *ydata*.

        Additional keyword arguments are `.Line2D` properties:

        %(Line2D:kwdoc)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.colorzlines.markersizezlines.antialiasedzlines.dash_capstylezlines.dash_joinstylezlines.solid_capstylezlines.solid_joinstylery   r   TF)>ÚsuperÚ__init__r<   rV   Ú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_offsetr'   Ú_pickerr   ÚboolÚasarrayÚ_xorigÚ_yorigÚ	_invalidxÚ	_invalidyr…   r†   Ú_xyr   Ú_transformed_pathÚ	_subsliceÚ	_x_filledÚset_data)r‰   ÚxdataÚydatarm   rl   rj   Úmarkerrr   ro   rn   rp   rq   Z	fillstyleri   Zdash_capstyleZsolid_capstyleZdash_joinstyleZsolid_joinstyler³   rk   rX   Úkwargs)Ú	__class__r1   r2   rŽ     s     "


















zLine2D.__init__c          	   C   sV  |   |¡\}}|dk	r||fS | js*| jr2|  ¡  t| jƒdkrHd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j | jd	krt ||j d
 |	|j d
  |
d
 k¡\}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 *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)Úall)r&   Nr9   rz   )Úind)Z_default_containsr»   rº   Úrecacher;   r¼   Ú_get_transformed_pathÚget_transformed_path_and_affineZtransform_pathrL   ÚfigureÚ_logÚwarningr³   Údpir<   ZerrstateÚ
_linestyler=   r5   r@   rI   r˜   Ú
startswithr´   Údict)r‰   Z
mouseeventZinsideÚinfoZtransformed_pathÚpathrZ   ÚxyZxtZytZpixelsrÈ   r1   r1   r2   Ú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‰   r1   r1   r2   Úget_pickradiusä  s    zLine2D.get_pickradiusc             C   s$   t |tƒr|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   r,   r×   )r‰   Údr1   r1   r2   Úset_pickradiusì  s    zLine2D.set_pickradiusc             C   s
   | j  ¡ S )z[
        Return the marker fill style.

        See also `~.Line2D.set_fillstyle`.
        )r£   Úget_fillstyle)r‰   r1   r1   r2   rÛ   ý  s    zLine2D.get_fillstylec             C   s    |   t| 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)Ú
set_markerr   r£   Ú
get_markerÚstale)r‰   Úfsr1   r1   r2   Úset_fillstyle  s    zLine2D.set_fillstylec             C   s   || _ d| _dS )af
  
        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 index
              *start*, will be plotted.
            - ``every=slice(start, end, N)``: every N-th marker, starting at
              index *start*, up to but not including index *end*, will be
              plotted.
            - ``every=[i, j, m, ...]``: only markers at the given indices
              will be plotted.
            - ``every=[True, False, True, ...]``: only positions that are True
              will be plotted. The list must have the same length as the data
              points.
            - ``every=0.1``, (i.e. a float): markers will be spaced at
              approximately equal visual 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): similar
              to ``every=0.1`` but the first marker will be offset along the
              line by 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 *markevery* will still only draw markers at actual data points.
        While the float argument form aims for uniform visual spacing, it has
        to coerce from the ideal spacing to the nearest available data point.
        Depending on the number and distribution of data points, the result
        may still not look evenly spaced.

        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everyr1   r1   r2   r§     s    8zLine2D.set_markeveryc             C   s   | j S )zr
        Return the markevery setting for marker subsampling.

        See also `~.Line2D.set_markevery`.
        )r¤   )r‰   r1   r1   r2   Úget_markeveryT  s    zLine2D.get_markeveryc             C   s    t |ƒr|| _n|| _|| _dS )zæ
        Set 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)ÚcallableZ	_containsr³   rµ   )r‰   Úpr1   r1   r2   Ú
set_picker\  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_transformrN   Zupdate_from_data_xyÚ
get_xydatar£   r¥   rÌ   rÏ   Zpadded)r‰   ÚrendererZbboxZtrans_data_to_xyrh   r1   r1   r2   Úget_window_extentk  s    

zLine2D.get_window_extentc             G   s8   t |ƒdkr|\\}}n|\}}|  |¡ |  |¡ 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‰   Úargsr5   r@   r1   r1   r2   rÀ   v  s
    
zLine2D.set_datac             C   s   | j dd d S )NT)Úalways)rÉ   )r‰   r1   r1   r2   Úrecache_always†  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rPt|ƒdkrP|  |¡rP| jjdkrP| j ¡ dkrP| jd krP|  ¡ rP|  ¡ | jjkrPd| _t
 |¡}| ¡ rH| j ¡ | _t
 t|ƒ¡}t
  || ||  | j|  ¡| j|< n| j| _| j!d k	rf| 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>   r…   r»   Zconvert_yunitsr¹   r†   r<   Zcolumn_stackZbroadcast_arraysZastypeÚfloatr¼   rQ   r¾   Úaxesr;   Ú
_is_sortedÚnameZ
get_xscaler¤   Zget_clip_onrå   Ú	transDataÚisnanÚanyÚcopyr¿   rS   Zinterpr   rî   r   r˜   r   r·   r½   )
r‰   rì   Zxconvr5   Zyconvr@   ZnanmaskÚindicesZinterpolation_stepsrÕ   r1   r1   r2   rÉ   ‰  sD    

"


$

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®
        Put a TransformedPath instance at self._transformed_path;
        all invalidation of the transform is then handled by the
        TransformedPath instance.
        N)rî   )r   r˜   r¼   rQ   r   r<   r·   r   rî   r   rå   r½   )r‰   ÚsubslicerÕ   r   r1   r1   r2   Ú_transform_path´  s    zLine2D._transform_pathc             C   s   | j dkr|  ¡  | j S )z<Return this line's `~matplotlib.transforms.TransformedPath`.N)r½   rù   )r‰   r1   r1   r2   rÊ   Ã  s    
zLine2D._get_transformed_pathc                s   d| _ d| _tƒ  |¡ d S )NT)rº   r»   r   Úset_transform)r‰   Út)rÅ   r1   r2   rú   É  s    zLine2D.set_transformc             C   s
   t  |¡S )z.Return whether x is sorted in ascending order.)r   Z	is_sorted)r‰   r5   r1   r1   r2   rñ   Ï  s    zLine2D._is_sortedc          	   C   sb  |   ¡ sd S | js| jr |  ¡  d| _| jrˆ| jrˆ| j ¡ \}}| j 	|d¡}| j 	|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%¡ |  &¡ rZ| j'}| j(}n| j)}| j*}|
 +|¡ |
 ,|¡ |
 -|  .¡ ¡ |  /¡ d k	r¤|
j0|  /¡ Ž  |
 1| j2| j3¡ | 4|
||	 5¡ ¡ |
 6¡  | j7rN| j8dkrN| ¡ }
|  |
¡ |
 |  ¡ ¡ |
 $| j9¡ |
 "| j#¡ t |  :¡ | j ¡}t |  ;¡ | j ¡}t | j;dd
| j ¡}t< =| j>d¡rŒt< ?|  @¡ d¡sŒ|d d… |d f }|
j!|dd	 |  /¡ d k	rÐ|  /¡ \}}}|
 0|d |d d| ¡ | j7}|  A¡ dkr$t<jB| dd d( |  ¡  |  |¡ |  ¡  C¡ \}}	W d Q R X n|  ¡  C¡ \}}	t|jƒrF|  D¡ }|d k	rdtE|||	| jƒ}n|}| F¡ }tG|tHƒrŒ| I| j8¡|k}|
 -|¡ |
 +| J¡ ¡ |
 ,| K¡ ¡ | L¡ }| M¡ }| I| j8¡}t< =| N¡ d¡rì|
 $d¡ n
| O|¡}| P|
||||	 5¡ |¡ | Q¡ }|rF| R¡ }| O|¡}| P|
||||	 5¡ |¡ |
 6¡  | Sd¡ d| _Td S )Nr   ÚleftÚrightr   )ÚPathEffectRendererZline2drt   T)ZisRGBA)ÚaltÚautor‹   rƒ   r9   ry   )r˜   r½   r„   F)UZget_visibler»   rº   rÉ   r´   r¾   rð   Z
get_xboundr¿   ZsearchsortedrM   Úmaxr\   rù   Zget_path_effectsZmatplotlib.patheffectsrþ   Z
open_groupZget_gidÚ_lineStylesrÐ   rÊ   rË   r;   rL   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ÚfrozenÚrestorer£   r¥   r«   Úget_markeredgecolorÚ_get_markerfacecolorr   Ú
_str_equalrª   Ú_str_lower_equalÚget_markerfacecolorÚget_drawstyleZ_setattr_cmZ!get_transformed_points_and_affinerá   rd   Zget_snap_thresholdr'   r   Zpoints_to_pixelsZget_joinstyleZget_capstyleÚget_pathrå   rÝ   rb   Zdraw_markersZget_alt_pathZget_alt_transformZclose_grouprÞ   )r‰   rç   r_   r`   Zi0Úi1rø   rþ   rY   rZ   ÚgcZlc_rgbaÚcapr‡   Zec_rgbaZfc_rgbaZ
fcalt_rgbarb   ÚlengthZ
randomnessrÃ   rX   Z
subsampledZsnapZmarker_pathZmarker_transÚwZalt_marker_pathZalt_marker_transr1   r1   r2   ÚdrawÔ  sÆ    











zLine2D.drawc             C   s   | j S )z-Return whether antialiased rendering is used.)r¦   )r‰   r1   r1   r2   Úget_antialiased[  s    zLine2D.get_antialiasedc             C   s   | j S )zP
        Return the line color.

        See also `~.Line2D.set_color`.
        )r¡   )r‰   r1   r1   r2   Ú	get_color_  s    zLine2D.get_colorc             C   s   | j S )zS
        Return the drawstyle.

        See also `~.Line2D.set_drawstyle`.
        )r˜   )r‰   r1   r1   r2   r  g  s    zLine2D.get_drawstylec             C   s   | j S )zS
        Return the linestyle.

        See also `~.Line2D.set_linestyle`.
        )rÐ   )r‰   r1   r1   r2   Úget_linestyleo  s    zLine2D.get_linestylec             C   s   | j S )z]
        Return the linewidth in points.

        See also `~.Line2D.set_linewidth`.
        )r™   )r‰   r1   r1   r2   Úget_linewidthw  s    zLine2D.get_linewidthc             C   s
   | j  ¡ S )zR
        Return the line marker.

        See also `~.Line2D.set_marker`.
        )r£   rÝ   )r‰   r1   r1   r2   rÝ     s    zLine2D.get_markerc             C   sX   | j }t |d¡rPtd rJ| j ¡ dkr.| jS | j ¡ rJ| j ¡ dkrJd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¡   Z	is_filledrÛ   )r‰   rg   r1   r1   r2   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‰   r1   r1   r2   Úget_markeredgewidth™  s    zLine2D.get_markeredgewidthc             C   s<   | j  ¡ dkrdS |r| jn| j}t |d¡r4| jS |S d S )Nr‹   r   )r£   rÛ   r­   r¬   r   r  r¡   )r‰   rÿ   Úfcr1   r1   r2   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‰   r1   r1   r2   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‰   r1   r1   r2   Ú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‰   r1   r1   r2   Úget_markersizeº  s    zLine2D.get_markersizeTc             C   s   | j |d| j|dfS )z}
        Return the line data as an ``(xdata, ydata)`` pair.

        If *orig* is *True*, return the original data.
        )Úorig)Ú	get_xdataÚ	get_ydata)r‰   r   r1   r1   r2   Ú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É   r…   )r‰   r   r1   r1   r2   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É   r†   )r‰   r   r1   r1   r2   r"  ×  s
    zLine2D.get_ydatac             C   s   | j s| jr|  ¡  | jS )z=Return the `~matplotlib.path.Path` associated with this line.)r»   rº   rÉ   r   )r‰   r1   r1   r2   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¼   )r‰   r1   r1   r2   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‰   Úbr1   r1   r2   r¨   ò  s    
zLine2D.set_antialiasedc             C   s   t j|d || _d| _dS )zi
        Set the color of the line.

        Parameters
        ----------
        color : color
        )rj   TN)r  Z_check_color_liker¡   rÞ   )r‰   rj   r1   r1   r2   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`.
        Nry   )rk   T)r   Úcheck_in_listÚ
drawStylesr˜   rÞ   rº   )r‰   rk   r1   r1   r2   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Þ   r8   r   rœ   r›   rš   )r‰   r  r1   r1   r2   rž   -  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'``, ``'None'``, ``' '``, 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`.
        )rw   rx   r‹   r&   )rf   z--N)r'   r(   r   r%  r  r   rÐ   r3   r   rœ   r8   r™   r›   rš   )r‰   rf   r1   r1   r2   rŸ   ?  s    

zLine2D.set_linestylec             C   s   t || 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   r£   rÛ   rÞ   )r‰   rÃ   r1   r1   r2   rÜ   o  s    zLine2D.set_markerc             C   sz   |d kr|rt d|›  nd}d|› }t| |ƒ}|d krBd| _n(||k}t|tjƒr`| ¡ rjn|rjd| _t| ||ƒ d S )Nzlines.r   Ú_T)r   ÚgetattrrÞ   r'   r<   Zndarrayrõ   Úsetattr)r‰   rò   Zhas_rcdefaultÚvalÚattrÚcurrentZneqr1   r1   r2   Ú_set_markercolor}  s    

zLine2D._set_markercolorc             C   s   |   dd|¡ dS )zf
        Set the marker edge color.

        Parameters
        ----------
        ec : color
        rn   TN)r-  )r‰   Úecr1   r1   r2   r°   ‹  s    zLine2D.set_markeredgecolorc             C   s   |   dd|¡ dS )zf
        Set the marker face color.

        Parameters
        ----------
        fc : color
        rp   TN)r-  )r‰   r  r1   r1   r2   r®   •  s    zLine2D.set_markerfacecolorc             C   s   |   dd|¡ dS )zp
        Set the alternate marker face color.

        Parameters
        ----------
        fc : color
        rq   FN)r-  )r‰   r  r1   r1   r2   r¯   Ÿ  s    zLine2D.set_markerfacecoloraltc             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‰   Úewr1   r1   r2   r±   ©  s
    	
zLine2D.set_markeredgewidthc             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‰   Úszr1   r1   r2   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‰   r5   r1   r1   r2   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‰   r@   r1   r1   r2   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.

        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.
        )NNr   ru   N)r;   rŸ   )r‰   Úseqr1   r1   r2   r  Þ  s    zLine2D.set_dashesc                s®   t ƒ  |¡ |j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	|j
| _
|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _t|jd| _|j| _dS )z%Copy properties from *other* to self.)rÃ   N)r   Úupdate_fromrÐ   r™   r¡   r¥   r¬   r­   rª   r«   rš   rœ   r›   r   r   r‘   r“   r’   r   r£   r˜   )r‰   Úother)rÅ   r1   r2   r2  ó  s(    zLine2D.update_fromc             C   s"   t |ƒ}| j|krd| _|| _dS )zÜ
        How to join segments of the line if it `~Line2D.is_dashed`.

        The default joinstyle is :rc:`lines.dash_joinstyle`.

        Parameters
        ----------
        s : `.JoinStyle` or %(JoinStyle)s
        TN)r   r‘   rÞ   )r‰   Úsr€   r1   r1   r2   r•     s    
zLine2D.set_dash_joinstylec             C   s"   t |ƒ}| j|krd| _|| _dS )zæ
        How to join segments if the line is solid (not `~Line2D.is_dashed`).

        The default joinstyle is :rc:`lines.solid_joinstyle`.

        Parameters
        ----------
        s : `.JoinStyle` or %(JoinStyle)s
        TN)r   r’   rÞ   )r‰   r4  r€   r1   r1   r2   r—     s    
zLine2D.set_solid_joinstylec             C   s   | j jS )zl
        Return the `.JoinStyle` for dashed lines.

        See also `~.Line2D.set_dash_joinstyle`.
        )r‘   rò   )r‰   r1   r1   r2   Úget_dash_joinstyle+  s    zLine2D.get_dash_joinstylec             C   s   | j jS )zl
        Return the `.JoinStyle` for solid lines.

        See also `~.Line2D.set_solid_joinstyle`.
        )r’   rò   )r‰   r1   r1   r2   Úget_solid_joinstyle3  s    zLine2D.get_solid_joinstylec             C   s"   t |ƒ}| j|krd| _|| _dS )zÙ
        How to draw the end caps if the line is `~Line2D.is_dashed`.

        The default capstyle is :rc:`lines.dash_capstyle`.

        Parameters
        ----------
        s : `.CapStyle` or %(CapStyle)s
        TN)r   r   rÞ   )r‰   r4  r|   r1   r1   r2   r”   ;  s    
zLine2D.set_dash_capstylec             C   s"   t |ƒ}| j|krd| _|| _dS )zå
        How to draw the end caps if the line is solid (not `~Line2D.is_dashed`)

        The default capstyle is :rc:`lines.solid_capstyle`.

        Parameters
        ----------
        s : `.CapStyle` or %(CapStyle)s
        TN)r   r“   rÞ   )r‰   r4  r|   r1   r1   r2   r–   K  s    
zLine2D.set_solid_capstylec             C   s   | j jS )zj
        Return the `.CapStyle` for dashed lines.

        See also `~.Line2D.set_dash_capstyle`.
        )r   rò   )r‰   r1   r1   r2   Úget_dash_capstyle[  s    zLine2D.get_dash_capstylec             C   s   | j jS )zj
        Return the `.CapStyle` for solid lines.

        See also `~.Line2D.set_solid_capstyle`.
        )r“   rò   )r‰   r1   r1   r2   Úget_solid_capstylec  s    zLine2D.get_solid_capstylec             C   s
   | j dkS )zÓ
        Return whether line has a dashed linestyle.

        A custom linestyle is assumed to be dashed, we do not inspect the
        ``onoffseq`` directly.

        See also `~.Line2D.set_linestyle`.
        )z--z-.rv   )rÐ   )r‰   r1   r1   r2   r  k  s    	zLine2D.is_dashed)NNNNNNNNr‹   NNNNNNrŒ   NN)F)N)F)T)T)T)XÚ__name__Ú
__module__Ú__qualname__Ú__doc__Ú
lineStylesr  Z_drawStyles_lZ_drawStyles_sr&  ZdrawStyleKeysr   ÚmarkersZfilled_markersÚ
fillstylesÚ
fillStylesZzorderr   Ú
deprecatedZclasspropertyr   r   rŠ   rŽ   rÖ   rØ   rÚ   Úpropertyr³   rÛ   rà   r§   rá   rä   rè   rÀ   rí   rÉ   rù   rÊ   rú   rñ   r   r  r  r  r  r  r  rÝ   r	  r  r
  r  r  r  r#  r!  r"  r  ræ   r¨   r¢   r    rž   rŸ   r
   ÚinterpdrÜ   r-  r°   r®   r¯   r±   r©   ré   rê   r  r2  r•   r—   r5  r6  r”   r–   r7  r8  r  Ú__classcell__r1   r1   )rÅ   r2   rs   Æ   sÎ                    xF
;
+
 
	


#0


rs   c                   s4   e Zd ZdZ‡ fd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                sX   t ƒ jddgddgf|Ž |d kr*|d ks:|d k	rB|d k	rBtdƒ‚|| _|| _|| _d S )Nr   r   z.Exactly one of 'xy2' and 'slope' must be given)r   rŽ   Ú	TypeErrorÚ_slopeÚ_xy1Ú_xy2)r‰   Zxy1Zxy2ÚsloperÄ   )rÅ   r1   r2   rŽ   }  s    z_AxLine.__init__c             C   sx  | j }| j|j |j }| jd k	r˜| | j| jg¡\\}}\}}|| }|| }t ||¡rŽt ||¡r†t	d||f› d||f› dƒ‚tj
}	q®|| }	n| | j¡\}}| j}	|j |j¡\\}
}\}}t |	d¡ræ|
|f}||f}nvt |	¡r||f}||f}nXt|
||
| |	  f|||| |	  f||| |	  |f||| |	  |fgƒ\}}}}tt||gƒƒ|j |j S )Nz3Cannot draw a line through two identical points (x=z, y=r‚   r   )rð   Z
_transformró   Z
transScalerI  rN   rH  r<   Zallcloser,   ÚinfrG  ZviewLimÚiscloseÚisinfÚsortedr   r   ZtransLimitsrR   )r‰   r[   Zpoints_transformr`   ra   Zx2Úy2rC   rD   rJ  ZvxloZvyloZvxhiZvyhir\   Ústopr'  r1   r1   r2   rå   ‰  s6    



 z_AxLine.get_transformc                s   d | _ tƒ  |¡ d S )N)r½   r   r  )r‰   rç   )rÅ   r1   r2   r  ²  s    z_AxLine.draw)r9  r:  r;  r<  rŽ   rå   r  rD  r1   r1   )rÅ   r2   rE  w  s   )rE  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 the `process_selected` method 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 `.Line2D`.  The line should already be
        added to an `~.axes.Axes` 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‰   rR  r1   r1   r2   rŽ   Õ  s    
zVertexSelector.__init__c             C   s   dS )a  
        Default "do nothing" implementation of the `process_selected` method.

        Parameters
        ----------
        ind : list of int
            The indices of the selected vertices.
        xs, ys : array-like
            The coordinates of the selected vertices.
        Nr1   )r‰   rÈ   ZxsZysr1   r1   r2   Úprocess_selectedè  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   rR  rÈ   rT  rN  r#  rU  )r‰   ÚeventrÈ   rÁ   rÂ   r1   r1   r2   rS  õ  s    
zVertexSelector.onpickN)r9  r:  r;  r<  rŽ   rU  rS  r1   r1   r1   r2   rQ  ·  s   rQ  )Br<  Únumbersr   r   r   ÚloggingÚnumpyr<   Z
matplotlibZmplrx   r   r   r   r	   r  r
   r   r   r   r   r   r   r   r>  r   rÔ   r   Z
transformsr   r   r   Z_enumsr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   Ú	getLoggerr9  rÍ   r3   r8   rI   rd   rC  Z_define_aliasesrs   rE  rQ  r  r=  ZlineMarkersr&  r?  r@  r1   r1   r1   r2   Ú<module>   s\    8
	%[
         -@H