a
    ضa                     @   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v r(d}d}nX| dv rHd}ttd|  }n8t | trr| \}}|du rtd| ntd| |durt|}|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   `/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/matplotlib/lines.py_get_dash_pattern   s$    

r3   c                    s>   t d s| |fS |   }|d ur2 fdd|D nd }||fS )Nzlines.scale_dashesc                    s    g | ]}|d ur|  nd qS Nr1   ).0xlwr1   r2   
<listcomp>A       z!_scale_dashes.<locals>.<listcomp>)r   )r/   r0   r8   Zscaled_offsetZscaled_dashesr1   r7   r2   _scale_dashes=   s    r;   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      Nr   )lennpnonzeroravelZconcatenate)Zcxcyr6   yZradiusresZxryrdxdyZLnorm_squ
candidatesZ
point_hitsZpxpyZ	line_hitsZpointslinesr1   r1   r2   segment_hitsF   s     ("  rL   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rt|tstd| t	|t
|d| ||t
|d|S t|tr t|tstd	| |du rt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nt| t
r2t	||  ||| S t| rzt	||  ||| W S  ttfy } ztd| d|W Y d}~n
d}~0 0 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u 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        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={}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axrN   ZvertsrM   startstepZdisp_coordsdeltax0Zy0x1y1scaleZmarker_deltaZindserrr1   r1   r2   _mark_every_pathk   sx    	





8$*


rg   ZaacZdslsr8   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i eeZg 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#dd2d3Z$dd4d5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 Z2ddNdOZ3dPdQ Z4dRdS Z5dTdU Z6ddWdXZ7ddYdZZ8dd[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 ZNeAjBdd ZOdd ZPdd ZQeAjBdd ZReAjBdd ZSdd ZTdd ZUdd 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)----.:r&     Z_draw_linesZ_draw_steps_midZ_draw_steps_preZ_draw_steps_post)defaultz	steps-midz	steps-prez
steps-poststepsr<   z3.4c                 C   s   t dd tD S )Nc                 s   s   | ]}|j V  qd S r4   value)r5   csr1   r1   r2   	<genexpr>   r:   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 r4   r   )r5   jsr1   r1   r2   r     r:   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 u 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 )Nr}   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u r>td }|du rNtd }|du r^td }|du rntd }|du r~td }|du rtd	 }|du rtd
 }|du rtd }|du rtd }|du rtd }|du rd}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_joinstyler~   r   TF)>super__init__r?   rY   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ydatarp   ro   rm   markerru   rr   rq   rs   rt   Z	fillstylerl   Zdash_capstyleZsolid_capstyleZdash_joinstyleZsolid_joinstyler   rn   r[   kwargs	__class__r1   r2   r     s    "



















zLine2D.__init__c                 C   sl  |  |\}}|du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u rtd | j}
n| j
jd | j }
tjddt | jd	v rt||j d
 |	|j d
  |
d
 k\}n*t|j|j||	|
}| jdr,|d
 }W d   n1 sB0    Y  || 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 line      R@ignore)all)r&   Nr<   r   )ind)Z_default_containsr   r   recacher>   r   _get_transformed_pathget_transformed_path_and_affineZtransform_pathrO   figure_logwarningr   dpir?   Zerrstate
_linestyler@   r6   rC   rL   r   
startswithr   dict)r   Z
mouseeventZinsideinfoZtransformed_pathpathr]   xyZxtZytZpixelsr   r1   r1   r2   contains  s:    


(
zLine2D.containsc                 C   s   | j S )zo
        Return the pick radius used for containment tests.

        See `.contains` for more details.
        )_pickradiusr   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_fillstyler   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   r   g      ?)
r   get_transformrQ   Zupdate_from_data_xy
get_xydatar   r   r   r   padded)r   rendererZbboxZtrans_data_to_xyrk   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   argsr6   rC   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 u rP|  rP|  | jjkrPd| _t
|}| rH| j | _t
t|}t
 || ||  | j|  | j|< n| j| _| j!d u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   rA   r   r   Zconvert_yunitsr   r   r?   Zcolumn_stackZbroadcast_arraysZastypefloatr   rT   r   axesr>   
_is_sortednameZ
get_xscaler   Zget_clip_onr   	transDataisnananycopyr   rV   Zinterpr   r   r   r   r   r   r   )
r   r   Zxconvr6   ZyconvrC   ZnanmaskindicesZinterpolation_stepsr   r1   r1   r2   r     sR    

"



zLine2D.recachec                 C   sZ   |du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.
        Nr   )r   r   r   rT   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u 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   tr   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   r6   r1   r1   r2   r     s    zLine2D._is_sortedc                 C   sx  |   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 }|  rd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 ur|
j0| /   |
1| j2| j3 |4|
||	5  |
6  | j7rd| j8dkrd| }
| |
 |
|   |
$| j9 |
"| j# t| : | j }t| ; | j }t| j;dd
| j }t<=| j>drt<?| @ ds|d d |d f }|
j!|dd	 | / d ur| / \}}}|
0|d |d d|  | j7}| A dkr:t<jB| dd d2 |   | | |  C \}}	W d    n1 s.0    Y  n|  C \}}	t|jr\| D }|d urztE|||	| 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 }|r\|R }|O|}|P|
||||	5 | |
6  |Sd d| _Td S )Nr   leftrightr   )PathEffectRendererZline2drw   T)ZisRGBAaltautor   r   r<   r~   )r   r   r   F)UZget_visibler   r   r   r   r   r   Z
get_xboundr   ZsearchsortedrP   maxr_   r  Zget_path_effectsZmatplotlib.patheffectsr  Z
open_groupZget_gid_lineStylesr   r   r   r>   rO   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   rg   Zget_snap_thresholdr'   r   Zpoints_to_pixelsZget_joinstyleZget_capstyleget_pathr   r   re   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_transr1   r1   r2   draw  s    







2






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v 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   rj   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`.
        Fr  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`.
        Tr  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   r0  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   r3  r1   r1   r2   r1    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   r3  r1   r1   r2   r2    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
        )rm   TN)r  Z_check_color_liker   r   )r   rm   r1   r1   r2   r     s    zLine2D.set_colorc                 C   s<   |du 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   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   r;   r   r   r   r   )r   r"  r1   r1   r2   r   -  s    	
zLine2D.set_linewidthc                 C   s|   t |trH|dv rd}tjg | jt|d || jv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`.
        )r|   r}   r   r&   )ri   ry   N)r'   r(   r   r6  r  r   r   r3   r   r   r;   r   r   r   )r   ri   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 u r|rt d|  nd}d| }t| |}|d u 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
        rq   TNr>  )r   Zecr1   r1   r2   r     s    zLine2D.set_markeredgecolorc                 C   s   |  dd| dS )zf
        Set the marker face color.

        Parameters
        ----------
        fc : color
        rs   TNr?  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
        rt   FNr?  r@  r1   r1   r2   r     s    zLine2D.set_markerfacecoloraltc                 C   s*   |du 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  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   rC   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   rx   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   otherr   r1   r2   rD    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`.

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

        Parameters
        ----------
        s : `.JoinStyle` or %(JoinStyle)s
        TN)r   r   r   rF  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_joinstyle/  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`.

        Parameters
        ----------
        s : `.CapStyle` or %(CapStyle)s
        TN)r   r   r   r   rG  r   r1   r1   r2   r   7  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`)

        Parameters
        ----------
        s : `.CapStyle` or %(CapStyle)s
        TN)r   r   r   rJ  r1   r1   r2   r   E  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_capstyleS  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_capstyle[  s    zLine2D.get_solid_capstylec                 C   s
   | j dv 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`.
        )ry   rz   r{   r&  r   r1   r1   r2   r  c  s    	zLine2D.is_dashed)NNNNNNNNr   NNNNNNr   NN)F)N)F)T)T)T)X__name__
__module____qualname____doc__
lineStylesr  Z_drawStyles_lZ_drawStyles_sr7  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/  r4  r1  r2  r  r   r   r   r   r   r   r
   interpdr   r>  r   r   r   r   r   r   r   r  rD  r   r   rH  rI  r   r   rK  rL  r  __classcell__r1   r1   r   r2   rv      s   
                   F
;
+

 
	


#0







rv   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                    s\   t  jddgddgfi | |d u r.|d u s>|d urF|d urFt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   u  s    z_AxLine.__init__c                 C   sx  | j }| j|j |j }| jd ur|| j| jg\\}}\}}|| }|| }t||rt||rt	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
transScaler]  rQ   r\  r?   Zallcloser,   infr[  ZviewLimiscloseisinfsortedr   r   ZtransLimitsrU   )r   r^   Zpoints_transformrc   rd   Zx2y2rF   rG   r^  ZvxloZvyloZvxhiZvyhir_   stopr8  r1   r1   r2   r     sL    



z_AxLine.get_transformc                    s   d | _ t | d S r4   )r   r   r#  )r   r   r   r1   r2   r#    s    z_AxLine.draw)rM  rN  rO  rP  r   r   r#  rX  r1   r1   r   r2   rY  o  s   )rY  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u rtd| du 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   rf  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   xsZysr1   r1   r2   process_selected  s    zVertexSelector.process_selectedc                 C   sV   |j | ju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   rf  r   rh  rb  r4  rj  )r   eventr   r   r   r1   r1   r2   rg    s    
zVertexSelector.onpickN)rM  rN  rO  rP  r   rj  rg  r1   r1   r1   r2   re    s   re  )BrP  Znumbersr   r   r   loggingZnumpyr?   Z
matplotlibZmplr}   r   r   r   r	   r  r
   r   r   r   r   r   r   r   rR  r   r   r   Z
transformsr   r   r   Z_enumsr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   	getLoggerrM  r   r3   r;   rL   rg   rW  Z_define_aliasesrv   rY  re  r  rQ  ZlineMarkersr7  rS  rT  r1   r1   r1   r2   <module>   s^    8
	%[         %@H