rL i@VdZddlZddlmZmZmZddlZddlZddl Z ddl m Z m Z mZmZddlmZmZddl mZmZmZmZddlmZdd lmZdd lmZmZmZdd l m!Z!m"Z"dd l m#Z#dd lm$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ej`e1Z2dZ3dZ4dZ5dZ6dZ7dZ8ejre jtdgdgdgdgdgdgdgdgdgdgd Gdd eZ;Gd!d"e;Z<Gd#d$Z=e;j|Z?ej0Z@e;jZAejZCy)%zK 2D lines with support for a variety of line styles, markers, colors, etc. N)IntegralNumberReal)_apicbookcolors _docstring)Artistallow_rasterization)_to_unmasked_float_array ls_mapper ls_mapper_rSTEP_LOOKUP_MAP) MarkerStyle)Path)BboxBboxTransformToTransformedPath) JoinStyleCapStyle)_path) CARETLEFT CARETRIGHTCARETUP CARETDOWN CARETLEFTBASECARETRIGHTBASE CARETUPBASE CARETDOWNBASETICKLEFT TICKRIGHTTICKUPTICKDOWNcDt|trtj||}|dvrd}d}nZ|dvr#d}t t j d|d}n3t|tr|\}}|td|td||t|}|r||z}||fS)z"Convert linestyle to dash pattern.)solidNonerN)dasheddashdotdottedlines._patternzUnrecognized linestyle: ) isinstancestrrgettuplemplrcParams ValueErrorsum)styleoffsetdashesdsums V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/lines.py_get_dash_patternr:!s% eU+ !! 1 1s||fUG8$<=> E5 ! >7yAB B3E9=>>6{  dNF 6>c t|g}|S#t$rF |Dcgc] }t|ncc}w}}Y|S#t$r}d|d}t||d}~wwxYwwxYw)zEConvert linestyle or sequence of linestyles to list of dash patterns.zDo not know how to convert z to dashesN)r:r3)stylespatternsxerremsgs r9_get_dash_patternsrB?s,%f-. O , ,6<=)!,==H= O  ,0 *EDT" + ,,s,  A;1; AAAAc0|dd|ddz}||dz}||fS)zCReturn the inverse of the given dash pattern, for filling the gaps.N)r6r7gaps offset_gapss r9_get_inverse_dash_patternrHMs5 "#; $D6":%K  r;ctjds||fS||z}||Dcgc] }|||znd c}nd}||fScc}w)Nzlines.scale_dashes)r1r2)r6r7lw scaled_offsetr? scaled_dashess r9 _scale_dashesrMYs` <<, -v~RKM*BHHA a"f47H04 - ''Is<cTt|dkr.tj||z dz||z dzz|dzk\}|S|dd|dd}}|dd|z |dd|z } }|dz| dzz} ||z |z||z | zz| z } | dk\| dkz} ||z dz||z dzz|dzk} | | dd| ddzz} || |zz|| | zz}}||z dz||z dzz|dzk}|| z}| jj\}|jj\}tj||fS)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*). rNrDr)lennpnonzeroravel concatenate)cxcyr?yradiusresxryrdxdyLnorm_squ candidates point_hitspxpy line_hitspointsliness r9 segment_hitsrgbs  1v{zz26a-26a-76Q;FG sVQsVBqrURZ12BQwq H r'R27b. (H4Aq&Q!V$J q&Q"q&Q.&A+=J 3B*QR. @AAJ!b&["q2v+BbQ"r'a/6Q;>IJ&I ((*GF __  & & (FE >>65/ **r;c n|j|j}}d}t|trd|f}nt|trd|f}t|t rYt |dk7rtd||\}}t|trJt|tstd|t|t|d|||t|d|St|trt|tstd|| td tj|jd } || } |j| } tjt | df} d| dddf<| d dddf| dd ddfz | d dddf<tj| j j#} |j$jddgd d gg\\} }\}}tj|| z ||z }tj&||z| d ||z}tj(| tj*ddf|ddtj*fz }|j-d }tj.|}t| ||||Std |dt|trt|||||Stj0|r t|||||Std |d#tt2f$r}td |d|d}~wwxYw)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|y||S)z@Helper function to cope with `codes` being an ndarray or `None`.NrE)in_vslcs r9_slice_or_nonez(_mark_every_path.._slice_or_nones <Cyr;rgrOz7`markevery` is a tuple but its len is not 2; markevery=zo`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)axisrDz 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)codesverticesr-rrr0rPr3rslicerQisfiniteall transformemptyhypotTcumsum transAxesarangeabsnewaxisargminuniqueiterable IndexError) markeverytpathaffineaxrnvertsrlstartstepfinfverts disp_coordsdeltax0y0x1y1scale marker_deltaindsr@s r9_mark_every_pathrsV;;5E)X& N It $)$ )U# y>Q **367 7 t dH %eX. !!* -.. eE467&ueE4.FGI Id #eT* !!* -..z >?? ++e$((a(0C3ZF **62KHHc+.23EE!Q$K&qr1u- CRCF0CCE!"a%LHHegg&--/E"$!7!7!Q!Q8H!I HRhr2HHR"Wb2g.E99UU]E"Ite|LL66% A .am1LLMD;;A;&D99T?Dt nUD&AB BYM*:;< < Iu %E)$nUI&FGG Y  )i(. *JK K :i]2LMNN J' )YM* %( ) )s+LL4L//L4aacdslsrJmecmewmfcmfcaltms) antialiasedcolor drawstyle linestyle linewidthmarkeredgecolormarkeredgewidthmarkerfacecolormarkerfacecoloralt markersizeceZdZdZddddddddxZZdd d d d Zd d iZieeZgeeZ e jZ e jZ e jZdZdZdZddddddddddddddddddddfd ZdZdZdZeeeZdZdZdZdZdZdZdSdZd Zd!Z dTd"Z!dSd#Z"d$Z#fd%Z$e%d&Z&d'Z'd(Z(d)Z)d*Z*d+Z+d,Z,d-Z-d.Z.d/Z/dTd0Z0d1Z1d2Z2d3Z3dUd4Z4dUd5Z5dUd6Z6d7Z7d8Z8d9Z9d:Z:d;Z;d<ZZ>e?jd?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJfdIZKe?jdJZLe?jdKZMdLZNdMZOe?jdNZPe?jdOZQdPZRdQZSdRZTxZUS)VLine2Da 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. _draw_solid _draw_dashed_draw_dash_dot _draw_dotted _draw_nothing)----.:r' _draw_lines_draw_steps_mid_draw_steps_pre_draw_steps_post)defaultz steps-midz steps-prez steps-poststepsrOic |jdk7rd|jdS|jyt|jdkDrddj|jd|jd|jd|jd|jd |jd Sd d j t d j|j|jzS) NrzLine2D()zLine2D()z/Line2D(({:g},{:g}),({:g},{:g}),...,({:g},{:g}))rrrDz Line2D(%s),z ({:g},{:g}))_label_xrPformat_yjoinmapselfs r9__str__zLine2D.__str__s ;;" T[[M+ + WW_ \A DKK DGGAJ DGGAJ TWWR[* *  #((M(($''477;#== =r;Nnone)rrrgapcolormarkerrrrrr fillstyler dash_capstylesolid_capstyledash_joinstylesolid_joinstyle pickradiusrrc t|tj|s t dtj|s t d|t j d}|t j d}|t j d}|t j d}|t j d}|t j d }|t j d }|t j d }|t j d }|t j d }|d}d|_d|_d|_ d|_ |j||j||j||j|d|_d|_||_d|_d|_|j)||j+||j-|d|_|j1||d}t3|t4st5|| |_n||_d|_|j;|d|_d|_d|_ |jC||jE||jG|d|_$d|_%d|_&d|_'|jQ| |jS| |jU| |jW| |jY|||_-d|_.t3|j^t`r+t3|j^tbs|j^|_2tjfg|_4tjfg|_5d|_6d|_7d|_8d|_9d|_:d|_;d|_<d|_=d|_>|j||y)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. zxdata must be a sequencezydata must be a sequenceNzlines.linewidthzlines.linestylez lines.markerz lines.colorzlines.markersizezlines.antialiasedzlines.dash_capstylezlines.dash_joinstylezlines.solid_capstylezlines.solid_joinstyler)rNrrTF)@super__init__rQr~ RuntimeErrorr1r2 _dashcapstyle_dashjoinstyle_solidjoinstyle_solidcapstyleset_dash_capstyleset_dash_joinstyleset_solid_capstyleset_solid_joinstyle _linestyles _drawstyle _linewidth_unscaled_dash_pattern _dash_pattern set_linewidth set_linestyle set_drawstyle_color set_colorr-r_marker _gapcolor set_gapcolor _markevery _markersize _antialiased set_markeveryset_antialiasedset_markersize_markeredgecolor_markeredgewidth_markerfacecolor_markerfacecoloraltset_markerfacecolorset_markerfacecoloraltset_markeredgecolorset_markeredgewidth_internal_updater ind_offset_pickerrbool _pickradiusasarray_xorig_yorig _invalidx _invalidyrr_xyr_transformed_path _subslice _x_filledset_data)rxdataydatarrrrrrrrrrrrrrrrrrrkwargs __class__s r9rzLine2D.__init__-saF {{5!9: :{{5!9: :   %67I   %67I >\\.1F =LL/E  &89J  ,,':;K  LL)>?M  ! \\*@AN  ! \\*@AN  "!ll+BCO  !I!"#" }- / /   1#&/#& 9% 9% 9%  u >F&+.&vy9DL!DL (#  9% [) J' $ $ $#'    1 ##$67   1   1 f%$ t||V ,t||T2#||D jjn jjn  !% eU#r;c|j|rdifS|js |jr|jt |j dk(rdifS|j }|j\}}|j|}|j}|dddf}|dddf}|jd}|"tjd|j} n|jdz |jz} tj d 5|j"d vrAtj$||j&z d z||j(z d zz| d zk\} nCt+|j&|j(||| } |j,j/d r| d z} ddd |j0z } t | dkDt3| fS#1swY2xYw)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 FrNrTrootz,no figure set when check if mouse is on lineR@ignore)rr)r'NrOr)ind)_different_canvasrrrecacherPr_get_transformed_pathget_transformed_path_and_affinetransform_pathro get_figure_logwarningrdpirQerrstate _linestylerRr?rWrgr startswithrdict) r mouseeventtransformed_pathpathrxyxtytfigpixelsrs r9containszLine2D.containss0  ! !* -"9  >>T^^ LLN txx=A "9  557'GGI f$$T* ]] 1X 1Xoo4o( ; LLG H%%FWWs]T%5%55F [[X & .0zz*,,&1,Z\\0Aa/GG{#$ #:<<r2vN??--g6AIC  t3x!|Tc]**!  s BGG!c|jS)zo Return the pick radius used for containment tests. See `.contains` for more details. )rrs r9get_pickradiuszLine2D.get_pickradius r;cRt|tr|dkr td||_y)z Set the pick radius used for containment tests. See `.contains` for more details. Parameters ---------- pickradius : float Pick radius, in points. rz pick radius should be a distanceN)r-rr3r)rrs r9set_pickradiuszLine2D.set_pickradiuss(*d+zA~?@ @%r;c6|jjS)z[ Return the marker fill style. See also `~.Line2D.set_fillstyle`. )r get_fillstylers r9r,zLine2D.get_fillstyles ||))++r;cx|jt|jj|d|_y)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_markerrr get_markerstale)rfss r9 set_fillstylezLine2D.set_fillstyle!s+"  DLL$;$;$=rBC r;c ||_d|_y)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)rr0)reverys r9rzLine2D.set_markevery5sp  r;c|jS)zr Return the markevery setting for marker subsampling. See also `~.Line2D.set_markevery`. )rrs r9 get_markeveryzLine2D.get_markeveryp r;cJt|s|j|||_y)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)callabler*r)rps r9 set_pickerzLine2D.set_pickerxs {    " r;cftddgddgg}|j|j|S)z"Get the bounding box of this line.r)rupdate_from_data_xy get_xydata)rbboxs r9get_bboxzLine2D.get_bboxs3aVaV$%   !23 r;cBtddgddgg}|jj}|j||j d|j r@|j dz |jdjzdz}|j|}|S)NrT)rr r g?) r get_transformrsr=r>rrrrpadded)rrendererr?trans_data_to_xyrs r9get_window_extentzLine2D.get_window_extentsaVaV$%--/99   !1$//2C!D(, ! . <<""T)DOOO,F,J,JJcQB;;r?D r;c~t|dk(r|\\}}n|\}}|j||j|y)z Set the x and y data. Parameters ---------- *args : (2, N) array or two 1D arrays See Also -------- set_xdata set_ydata rN)rP set_xdata set_ydata)rargsr?rWs r9rzLine2D.set_datas; t9>GFQDAq q qr;c(|jdy)NT)always)rrs r9recache_alwayszLine2D.recache_alwayss D !r;c|s |jr5|j|j}t|j }n |j }|s |j r5|j|j}t|j }n |j}tjtj||jt|_|jj \|_|_ d|_|j$r]t'||j(kDrDt+j,|r.|j$j.dk(r|j$j1dk(r|j2|j5r|j7|j$j8k(rd|_tj:|}|j=rw|j j?|_ tjBt'|}tjD|||||j ||j@|<n|j |_ |j*|j*jF}nd}tI|jJ|jj } tMtjN| j ||_d|_(d|_d|_y)NF rectilinearlinearTr_interpolation_steps))rconvert_xunitsrr rSrrconvert_yunitsrrrQ column_stackbroadcast_arraysastypefloatrrvraxesrP_subslice_optim_min_sizeris_sorted_and_has_non_nanname get_xscaler get_clip_onrB transDataisnananycopyrryinterprRrrrrr) rrLxconvr?yconvrWnanmaskindicesinterpolation_stepsr s r9rzLine2D.recaches* T^^'' 4E(/557AA T^^'' 4E(/557AA??2#6#6q!#<=DDUK88:: IIFT:::33A6IINNm3II((*h6OO+$$&&&(DII,?,??!DNhhqkG{{}!%))CF+*,))G$gwh&7'9J+Lw'"& :: !"&**"A"A "#  T__ -txxzz :"**R.**/BD !%r;c<|ot|j|j|ddfj}t t j |j|jj}n |j}t||j|_ y)z Put a TransformedPath instance at self._transformed_path; all invalidation of the transform is then handled by the TransformedPath instance. NrQ) rrrrvrrQrrrRrrBr)rsubslicer rs r9_transform_pathzLine2D._transform_paths{   1488HaK3H3J3JKBB)).2jj.M.MOEJJE!08J8J8L!Mr;cR|j|j|jS)z>T^^ LLN >>diiYY))+FB,,R8B,,R9BSa^R!V4H&nnDO   *H  " A)$*?*?*A8LHHdlln5   DOO , ?!779==? E65>>"__&!!"% 4<<>*""4#4#45  1>>#,,C..D--C//D  &$ DMMO,))+7(B(($*@*@*BC>>#(B%oodnndkkJG%%gd%;(A++)-%KMM+t4&&r5&--/B!//$++t{{C!!'$!7 t112""2ufmmo> <>" ..0 (!1!5&$))"=J"'J002dD)#44T5E5EF$ND D!  !5!5!78 3 3 56$oo/ %335 --d.>.>?##F$5$5$7=$$Q'$0#5#5a#8L%%b+|&0&--/&-/#)"5"5"7"'-'?'?'A$'7'='=a'@$))1A:"MMOZ9 JJLX& cKKs A`99ac|jS)z-Return whether antialiased rendering is used.)rrs r9get_antialiasedzLine2D.get_antialiaseds   r;c|jS)zP Return the line color. See also `~.Line2D.set_color`. )rrs r9 get_colorzLine2D.get_colors {{r;c|jS)zS Return the drawstyle. See also `~.Line2D.set_drawstyle`. )rrs r9rzLine2D.get_drawstyler7r;c|jS)zV Return the line gapcolor. See also `~.Line2D.set_gapcolor`. )rrs r9 get_gapcolorzLine2D.get_gapcolors ~~r;c|jS)zS Return the linestyle. See also `~.Line2D.set_linestyle`. rrs r9 get_linestylezLine2D.get_linestyler7r;c|jS)z] Return the linewidth in points. See also `~.Line2D.set_linewidth`. )rrs r9 get_linewidthzLine2D.get_linewidthr7r;c6|jjS)zR Return the line marker. See also `~.Line2D.set_marker`. )rr/rs r9r/zLine2D.get_markers ||&&((r;cH|j}tj|drtjdr`|j j dvr |jS|j jr|j jdk7ry|jS|S)za Return the marker edge color. See also `~.Line2D.set_markeredgecolor`. rxz_internal.classic_mode).rrk) rrrr1r2rr/r is_filledr,)rrs r9rzLine2D.get_markeredgecolors ##   C (||45<<**, :;;&LL**, LL668FB;; Jr;c|jS)zk Return the marker edge width in points. See also `~.Line2D.set_markeredgewidth`. )rrs r9get_markeredgewidthzLine2D.get_markeredgewidths $$$r;c|jjdk(ry|r |jn |j}t j |dr |j S|S)Nrrx)rr,rrrrr)rrwfcs r9rzLine2D._get_markerfacecolorsN << % % '6 1),T % %$2G2G  ! !"f -;; Ir;c&|jdS)za Return the marker face color. See also `~.Line2D.set_markerfacecolor`. Frvrrs r9rzLine2D.get_markerfacecolors ((U(33r;c&|jdS)zn Return the alternate marker face color. See also `~.Line2D.set_markerfacecoloralt`. Trvrrs r9get_markerfacecoloraltzLine2D.get_markerfacecoloralts ((T(22r;c|jS)z` Return the marker size in points. See also `~.Line2D.set_markersize`. )rrs r9get_markersizezLine2D.get_markersizer(r;cJ|j||j|fS)z} Return the line data as an ``(xdata, ydata)`` pair. If *orig* is *True*, return the original data. )orig) get_xdata get_ydatarrs r9get_datazLine2D.get_datas% ~~4~($..d.*CCCr;cn|r |jS|jr|j|jS)z| Return the xdata. If *orig* is *True*, return the original data, else the processed data. )rrrrrs r9rzLine2D.get_xdata* ;;  >> LLNwwr;cn|r |jS|jr|j|jS)z| Return the ydata. If *orig* is *True*, return the original data, else the processed data. )rrrrrs r9rzLine2D.get_ydata rr;cj|js |jr|j|jS)z=Return the `~matplotlib.path.Path` associated with this line.)rrrrrs r9rzLine2D.get_paths" >>T^^ LLNzzr;cj|js |jr|j|jS)z'Return the *xy* data as a (N, 2) array.)rrrrrs r9r>zLine2D.get_xydatas! >>T^^ LLNxxr;c>|j|k7rd|_||_y)zs Set whether to use antialiased rendering. Parameters ---------- b : bool TN)rr0)rbs r9rzLine2D.set_antialiased%s!    !DJr;cLtj|||_d|_y)zt Set the color of the line. Parameters ---------- color : :mpltype:`color` rTN)r_check_color_likerr0)rrs r9rzLine2D.set_color1s  !!.  r;c|d}tj|j||j|k7rd|_d|_||_y)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)rT)r check_in_list drawStylesrr0r)rrs r9rzLine2D.set_drawstyle=sD4  !I 4??i@ ??i 'DJ!DN#r;cP|tj|||_d|_y)a Set a color to fill the gaps in the dashed line style. .. note:: Striped lines are created by drawing two interleaved dashed lines. There can be overlaps between those two, which may result in artifacts when using transparency. This functionality is experimental and may change. Parameters ---------- gapcolor : :mpltype:`color` or None The color with which to fill the gaps. If None, the gaps are unfilled. NrT)rrrr0)rrs r9rzLine2D.set_gapcolor`s&$    % %H 5! r;ct|}|j|k7rd|_||_tg|j||_y)z Set the line width in points. Parameters ---------- w : float Line width, in points. TN)rXrr0rMrr)rrs r9rzLine2D.set_linewidthwsB !H ??a DJ*KD,G,GKKr;cHt|trN|dvrd}tjg|jt |||jvr t |}||_nd|_t||_tg|j|j|_ d|_ y)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`. )rrrr')rrTN) r-r.rrrrrr:rrMrrr0)rrs r9rzLine2D.set_linestyles> b# &&   @!1!1@K@R H))) _ DO"DO&7&;#*;  ( (;*.//; r;cdt||jj|_d|_y)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)rrr,r0)rrs r9r.zLine2D.set_markers&#64<<+E+E+GH  r;c||rtjd|nd}d|}t||}|d|_n9||k7}t |t j r|jr n|rd|_t|||y)Nr+rx_T) r1r2getattrr0r-rQndarrayrasetattr)rr\ has_rcdefaultvalattrcurrentneqs r9_set_markercolorzLine2D._set_markercolorsv ;3@#,,v/fC4&z$% ?DJS.C&sBJJ7swwyS! dC r;c*|jdd|y)zq Set the marker edge color. Parameters ---------- ec : :mpltype:`color` rTNr)recs r9rzLine2D.set_markeredgecolor /r:r;c*|jdd|y)zq Set the marker face color. Parameters ---------- fc : :mpltype:`color` rTNrrrs r9rzLine2D.set_markerfacecolorrr;c*|jdd|y)z{ Set the alternate marker face color. Parameters ---------- fc : :mpltype:`color` rFNrrs r9rzLine2D.set_markerfacecoloralts 2E2>r;ch|tjd}|j|k7rd|_||_y)z Set the marker edge width in points. Parameters ---------- ew : float Marker edge width, in points. Nzlines.markeredgewidthT)r1r2rr0)rews r9rzLine2D.set_markeredgewidths5 :56B  B &DJ "r;cTt|}|j|k7rd|_||_y)z Set the marker size in points. Parameters ---------- sz : float Marker size, in points. TN)rXrr0)rszs r9rzLine2D.set_markersizes*2Y   r !DJr;ctj|s tdtj||_d|_d|_y)z Set the data array for x. Parameters ---------- x : 1D array See Also -------- set_data set_ydata zx must be a sequenceTN)rQr~rrbrrr0)rr?s r9rHzLine2D.set_xdata 8{{1~56 6iil  r;ctj|s tdtj||_d|_d|_y)z Set the data array for y. Parameters ---------- y : 1D array See Also -------- set_data set_xdata zy must be a sequenceTN)rQr~rrbrrr0)rrWs r9rIzLine2D.set_ydatarr;ct|dk(st|dk(r|jdy|jd|fy)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. See also `~.Line2D.set_gapcolor`, which allows those spaces to be filled with a color. 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. )NNrrN)rPr)rseqs r9rzLine2D.set_dashes0s6& , #c(a-   s #   3x (r;ct|||j|_|j|_|j|_|j |_|j |_|j|_|j|_|j|_ |j|_ |j|_ |j|_ |j|_ |j|_|j|_|j |_|j|_t#|j$|_|j&|_y)z%Copy properties from *other* to self.)rN)r update_fromrrrrrrrrrrrrrrrrrr)rotherr s r9rzLine2D.update_fromHs E"****ll  ,, % 6 6#(#<#< % 6 6 % 6 6&+&B&B#"00"00#22#22$44**"%--8 **r;cTt|}|j|k7rd|_||_y)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)rrr0rsjss r9rzLine2D.set_dash_joinstyle_s*q\   " $DJ r;cTt|}|j|k7rd|_||_y)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)rrr0r s r9rzLine2D.set_solid_joinstyleos*q\   2 %DJ!r;c.|jjS)zl Return the `.JoinStyle` for dashed lines. See also `~.Line2D.set_dash_joinstyle`. )rr\rs r9get_dash_joinstylezLine2D.get_dash_joinstyle ""'''r;c.|jjS)zl Return the `.JoinStyle` for solid lines. See also `~.Line2D.set_solid_joinstyle`. )rr\rs r9get_solid_joinstylezLine2D.get_solid_joinstyles ##(((r;cTt|}|j|k7rd|_||_y)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)rrr0rr css r9rzLine2D.set_dash_capstyles*a[    #DJr;cTt|}|j|k7rd|_||_y)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)rrr0rs r9rzLine2D.set_solid_capstyles*a[   " $DJ r;c.|jjS)zj Return the `.CapStyle` for dashed lines. See also `~.Line2D.set_dash_capstyle`. )rr\rs r9get_dash_capstylezLine2D.get_dash_capstyles !!&&&r;c.|jjS)zj Return the `.CapStyle` for solid lines. See also `~.Line2D.set_solid_capstyle`. )rr\rs r9get_solid_capstylezLine2D.get_solid_capstylerr;c|jdvS)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`. )rrrrrs r9rzLine2D.is_dasheds"333r;N)F)T)V__name__ __module__ __qualname____doc__ lineStylesr _drawStyles_l _drawStyles_sr drawStyleKeysrmarkersfilled_markers fillstyles fillStyleszorderrZrrr%r'r*propertyrr,r2rr6r;r@rFrrMrrkrrnr rrrrrrrr/rrrrrrrrrrr>rrrrrrr interpdr.rrrrrrrHrIrrrrrrrrrrr __classcell__r s@r9rrs  J$''( M "M 4M3]3J4m4m4M!!G //N''J F# =  !%!%!%$*!# $ $!%'K$ZD+L  &..9J,(9v  *"+Z N& ! OOb!)$%43 D     !$F. L+Z   !;;? # &&)0+. ! ! " "()     ! !'( 4r;rcVeZdZdZfdZdZfdZdZdZdZ dZ d Z d Z xZ S) AxLinezo A helper class that implements `~.Axes.axline`, by recomputing the artist transform at draw time. c t|ddgddgfi|||| | td||_||_||_y)a Parameters ---------- xy1 : (float, float) The first set of (x, y) coordinates for the line to pass through. xy2 : (float, float) or None The second set of (x, y) coordinates for the line to pass through. Both *xy2* and *slope* must be passed, but one of them must be None. slope : float or None The slope of the line. Both *xy2* and *slope* must be passed, but one of them must be None. rrNz.Exactly one of 'xy2' and 'slope' must be given)rr TypeError_slope_xy1_xy2)rxy1xy2sloperr s r9rzAxLine.__init__s] !Q!Q262 KEME$5@B B   r;cH|j}|j|jz |jz}|jq|j |j |jg\\}}\}}||z }||z }|dk(r,|dk(rtd||fd||fdtj} n0||z } n*|j |j \}}|j} |jj |j\\} } \} } | dk(r | |f}| |f}n^tj| r || f}|| f}n@t| || |z | zzf| || |z | zzf|| |z | z z| f|| |z | z z| fg\}}}}tt||g|j z|j"zS)Nrz3Cannot draw a line through two identical points (x=z, y=r)rY _transformr_ transScaler3rsr2r3rQinfr1viewLimisinfsortedrr transLimitsrx)rrpoints_transformrrx2y2r\r]r6vxlovylovxhivyhirstoprs r9rBzAxLine.get_transforms YY??R\\9BMMI 99 !**DIItyy+AB HRhr2bBbBQw7$!2hZtRH:Q899R&// :FBKKE%']]%<%z AxLine.set_xy1..,svxr;ctSrrQ)rr4s r9rTz AxLine.set_xy1..,s68r;r?3.10zpPassing x and y separately to AxLine.set_xy1 is deprecated since %(since)s; pass them as a single tuple instead.messagerWr4N)rselect_matching_signaturewarn_deprecatedr2)rrJrparamsr4s r9set_xy1zAxLine.set_xy1"s// ')C1 "" " &=  B D+vc{*C -C r;c|jXtjddg|g|i|}d|vr)tjdd|d|df}||_y|d }||_yt d ) av Set the *xy2* value of the line. .. note:: You can only set *xy2* if the line was created using the *xy2* parameter. If the line was created using *slope*, please use `~.AxLine.set_slope`. Parameters ---------- xy2 : tuple[float, float] Points for the line to pass through. NctSrrQrSs r9rTz AxLine.set_xy2..Hs68r;ctSrrQ)rr5s r9rTz AxLine.set_xy2..Hsvxr;r?rVzpPassing x and y separately to AxLine.set_xy2 is deprecated since %(since)s; pass them as a single tuple instead.rWrWr5z]Cannot set an 'xy2' value while 'slope' is set; they differ but their functionalities overlap)r1rrYrZr3r3)rrJrr[r5s r9set_xy2zAxLine.set_xy27s ;; 33+-G5&&$&Ff}$$VFHSk6#;.DIUmDINO Or;c@|j||_ytd)a^ Set the *slope* value of the line. .. note:: You can only set *slope* if the line was created using the *slope* parameter. If the line was created using *xy2*, please use `~.AxLine.set_xy2`. Parameters ---------- slope : float The slope of the line. Nz\Cannot set a 'slope' value while 'xy2' is set; they differ but their functionalities overlap)r3r1r3)rr6s r9 set_slopezAxLine.set_slopeVs* 99 DKNO Or;)rrrrrrBrrIrLrNr\r`rbr+r,s@r9r.r.s8 0'1R*O>Or;r.c4eZdZdZdZedZdZdZy)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): super().__init__(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 |j td|j td|j|_||_|jj j d|j|_t|_ y)z Parameters ---------- line : `~matplotlib.lines.Line2D` The line must already have been added to an `~.axes.Axes` and must have its picker property set. Nz'You must first add the line to the Axesz2You must first set the picker property of the line pick_event) rYr get_pickerlinecanvas callbacks_connect_picklableonpickcidsetr)rrhs r9rzVertexSelector.__init__sy 99 HI I ??  $ -. .II  ;;((;; $++'5r;cN|jjdjS)NTr )rYrrirs r9rTzVertexSelector.s499#7#7T#7#B#I#Ir;cy)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. NrE)rrxsyss r9process_selectedzVertexSelector.process_selecteds r;c|j|jury|xjt|jzc_t |j}|jj \}}|j |||||y)zrsN **88/GG >>'++++ w"<  ("+J\O~ 6Uwww#*&  U4VU4 U4p&^OV^OBF;F;R   !!     # # r;