rL iJdZddlZddlZddlZddlmZddlZddlZddl Z ddl m Z m Z mZmZddl mZddlmZddlmZmZmZdd lmZmZdd lmZmZmZmZmZm Z ejBe"Z#d Z$d Z%ejLd dZ'ejPe jRdgddgdgdgdgdgdgdgdgdgdgdgd GddeZ*Gdd Z+Gd!d"Z,Gd#d$e*e,Z-ejPj]e-j^j%y)&z) Classes for including text in a figure. N)Real)_apiartistcbook _docstring)Artist)FontProperties)FancyArrowPatchFancyBboxPatch Rectangle)TextPath TextToPath)Affine2DBboxBboxBaseBboxTransformToIdentityTransform Transformc0g}g}tj|j}tj | }|j |\}}}|D]W\} } } } | \} }|j | | f\}}||z}|| z||z}}|j||g|j||gYt|t|}}t||z t||z }}tj |j ||f\}}||||fS)z Calculate the bounding box of the text. The bbox position takes text rotation into account, but the width and height are those of the unrotated box (unlike `.Text.get_window_extent`). ) npdeg2rad get_rotationrrotate _get_layout transformextendminmax)textrenderer projected_xs projected_ysthetatr_partsdtwhxywhxt1yt1xt2yt2xt_boxyt_boxw_boxh_boxx_boxy_boxs U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/text.py _get_textboxr:s*LL JJt((* +E   E6 "B""8,KAua( 2q!1<<A'S q7C!GSS#J'S#J'(&L(9FF|$v-s 7 7h OOr;cfontfont_propertiesfamilynamesizestretchstylevariantweighthavama) colorfontproperties fontfamilyfontnamefontsize fontstretch fontstyle fontvariant fontweighthorizontalalignmentverticalalignmentmultialignmentceZdZdZdZeZdZ dRdddddddddddddd fd Z dSd Z fd Z fd Z d Z dZ dZdZdZdZdZdZdZdZfdZdZdZdZdZdZfdZdTfd ZfdZd Zd!Z d"Z!d#Z"d$Z#d%Z$e%jLd&Z'd'Z(d(Z)d)Z*d*Z+d+Z,d,Z-d-Z.d.Z/d/Z0d0Z1d1Z2d2Z3d3Z4d4Z5dUd5Z6d6Z7d7Z8d8Z9d9Z:d:Z;d;Zd>Z?d?Z@d@ZAdAZBdBZCdCZDdDZEdEZFdFZGdGZHdHZIdIZJdJZKdKZLeMjdLdMZOdNZPdOZQdPZRdQZSxZTS)VTextzAHandle storing and drawing of text in window or data coordinates.cVd|jd|jd|jdS)NzText(, ))_x_y_textselfs r9__repr__z Text.__repr__es)twwir$''"TZZN!< ?zz&(+ 57>&)* x  JJt}}T* + r;c.t|}d|d<|S)Nr)rz __getstate__)rlr(rs r9rzText.__getstate__s G "+r;c|j|s|jr |jdifStj |}|j |j cxkxr|jkncxr.|j|jcxkxr|jknc}i}|jr)|jj|\}}|xs|}||d<||fS)zs Return whether the mouse event occurred inside the axis-aligned bounding-box of the text. F bbox_patch) _different_canvas get_visiblerrcget_window_extentx0r+x1y0r,y1rcontains)rl mouseeventrinsidecattr patch_inside patch_cattrs r9rz Text.containss  " ": .d6F6F6H>>)"9 %%d+''Z\\4TWW49gg88    (,(8(8(A(A*(M %L++|F"-E, u}r;cj|j\}}|jj||fS)zW Get the (possibly unit converted) transformed x, y in display coords. )get_unitless_position get_transformrrlr+r,s r9_get_xy_displayzText._get_xy_displays4))+1!!#--q!f55r;cJ|j |jS|jSrF)r_horizontalalignmentrks r9_get_multialignmentzText._get_multialignments&    +'' ',, ,r;c|jsy|j}t|j}|tjvrt tj|<tj|}t |D]D}||vs|j||j}|j|jz ||<F|j||j}tjdg|Dcgc]}|| c}z}|jz }tj||z jScc}w)a Calculate the index closest to the coordinate x in display space. The position of text[index] is assumed to be the sum of the widths of all preceding characters text[:index]. This works only on single line texts. r)rjstr_fontpropertiesrc_charsize_cachedictsetrrrrrcumsumabsargmin) rlr+r rWcharsize_cachecharbb size_accumstd_xs r9_char_index_atzText._char_index_atszzzzT112 !5!5 5376D  0--n=I 5D>) d#++-')uuruu}t$  5 d  # # %YYs%FAnQ&7%FFG BEE zE)*2244&Gs7 E c|jrI|jj|jg|j gj dS|jS)z3Return the text angle in degrees between 0 and 360.r)get_transform_rotates_textrtransform_angles _rotationritemrks r9rzText.get_rotationsY  * * ,%%'88 4#=#=#?"@BBF$q' J>> !r;c|jS)zV Return whether rotations of the transform affect the text direction. )rrks r9rzText.get_transform_rotates_text$s+++r;cX|d}ntjd|||_d|_y)a Set text rotation mode. Parameters ---------- m : {None, 'default', 'anchor'} If ``"default"``, the text will be first rotated, then aligned according to their horizontal and vertical alignments. If ``"anchor"``, then alignment occurs before rotation. Passing ``None`` will set the rotation mode to ``"default"``. Ndefault)anchorr)rrT)r check_in_list_rotation_modestale)rlms r9rzText.set_rotation_mode*s. 9A   4A F r;c|jS)zReturn the text rotation mode.)rrks r9get_rotation_modezText.get_rotation_mode=s"""r;c ||_d|_y)aG Set whether to use antialiased rendering. Parameters ---------- antialiased : bool Notes ----- Antialiasing will be determined by :rc:`text.antialiased` and the parameter *antialiased* will have no effect if the text contains math expressions. TN) _antialiasedr)rlrws r9rzText.set_antialiasedAs( r;c|jS)z-Return whether antialiased rendering is used.)rrks r9get_antialiasedzText.get_antialiasedRs   r;ct|||j|_|j|_|j|_|j |_|j j|_|j|_|j|_ |j|_ |j|_ |j|_ |j|_ d|_y)NT)rz update_from_colorr_verticalalignmentrrr@_usetexrr_picker _linespacingrr)rlotherrs r9rzText.update_fromVs E"ll $44"'":":$)$>$>!$4499;}} ','D'D$}} !..!.. r;c d\}}|jjd}g}g}g}g}t|d|j|j rdnd|j dj \} } } | | z |jz} t|D]\} }|j|\}}|r9t|||j||j dj \}}}nd x}x}}t|| }t|| }|j||j|||z |z }| d k(r||z }n|t| ||z |jzz}|j||j|||z}}t|}d }|}d }|d |z }tj|j}|j}|d k(r!t!||Dcgc] \}}||f }}}ne|d k(r1t!|||Dcgc]\}}}||d z z|d z z |f}}}}n/|dk(r*t!|||Dcgc]\}}}||z|z |f}}}}t#j$||f||f||f||fg} |j'| }!|!ddd fj)}|!ddd fj}|!dddfj)}|!dddfj}||z }||z }"|j*}#|j,}$|j/}%|%dk7rM|#d k(r ||zd z }&n |#dk(r|}&n|}&|$d k(r ||zd z }'n|$dk(r|}'n|$dk(r||z}'n|$dk(r ||"zdz z }'nr|}'no| d \}(})| d \}*}+|#d k(r |(|*zdz }&n |#dk(r|*}&n|(}&|$d k(r |)|+zdz }'n#|$dk(r|+}'n|$dk(r|+z }'n|$dk(r |+dz z }'n|)}'|j'|&|'f\}&}'||&z}||'z}t1j2||||"},|j'|&|'fz }-|,t5t!|t!||g|-j6|fScc}}wcc}}}wcc}}}w)z Return the extent (bbox) of the text together with multiple-alignment information. Note that it returns an extent of a rotated text when necessary. )r lpTeXFTroot)rBrCrrocenterrightNrrtoprncenter_baselineg@)_get_wrapped_textsplitrDr get_usetex get_figurerCr enumerate_preprocess_mathrrr rotate_degrrziprarrayrrrrrr from_boundslistT).rlr!thisxthisylineswshsxsysr&lp_hlp_dmin_dyiline clean_linerBr-r.r(rndescentwidthxminxmaxymaxyminMmalignr+r, offset_layout corners_horizcorners_rotatedheighthalignvalignrroffsetxoffsetyxmin1ymin1xmax1ymax1rxyss. r9rzText._get_layoutfs+  u&&(..t4    5 dD00 OO-55T*..0 4+!2!22 ' GAt!%!6!6t!< J6j$*>*>!tD'A'E'EG1a  A At AAt A IIaL IIaLAHAva%Va!et/@/@%@AA IIe  IIe  QJE? DB"v J ! !$"3"3"5 6))+ V 03B <1aV GW  dE6:kk-(GW+==T#eSR[93559:GCCa===s+QQ QcN||j}|jdd}|jdd}|d}|d}||jz}n|d}t|tr d|vr|d|zz }t d|t d ||_nd|_|jy) a Draw a bounding box around self. Parameters ---------- rectprops : dict with properties for `.patches.FancyBboxPatch` The default boxstyle is 'square'. The mutation scale of the `.patches.FancyBboxPatch` is set to the fontsize. Examples -------- :: t.set_bbox(dict(facecolor='red', alpha=0.5)) Nboxstylepadsquareg333333?z ,pad=%0.2f)rrrr)rr) r@rget_size isinstancerr rr_update_clip_properties)rl rectpropspropsrrs r9rz Text.set_bboxs"  NN$EyyT2H))E4(C#;Ct}}&;C(C(U(-BL3..- K!->-@ KDI KD  $D  $$&r;c|jS)zf Return the bbox Patch, or None if the `.patches.FancyBboxPatch` is not made. )rrks r9get_bbox_patchzText.get_bbox_patch&s r;cv|jr,t|j|j}t|j |j }|j j||f\}}t||\}}}}|jjdd|||jjtj|jj||z||z|j|j!}|jj#|yy)z Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox. rN)rfloatconvert_xunitsrhconvert_yunitsrirrr: set_bounds set_transformrrr translatepoints_to_pixelsr!set_mutation_scale) rlr!posxposyr7r8r5r6fontsize_in_pixels r9update_bbox_position_sizezText.update_bbox_position_size-s   ,,TWW56D,,TWW56D++-77t EJD$)5dH)E &E5%    ' 'Bu =    * * D--/04%<6 8!) 9 9$--/ J     / /0A B r;c|jrHt|j|j|j}|jj |yy)N)clip_box clip_pathclip_on)rrclipbox _clippath_cliponr})rl clippropss r9r#zText._update_clip_propertiesDsD   dll'+~~%)\\3I    # #I . r;cDt|||jyrF)rz set_clip_boxr#)rlr9rs r9r>zText.set_clip_boxKs W% $$&r;cFt||||jyrF)rz set_clip_pathr#)rlpathrrs r9r@zText.set_clip_pathPs dI. $$&r;cDt|||jyrF)rz set_clip_onr#)rlbrs r9rCzText.set_clip_onUs A $$&r;c|jS)z'Return whether the text can be wrapped._wraprks r9get_wrapz Text.get_wrapZ zzr;c||_y)a2 Set whether the text can be wrapped. Wrapping makes sure the text is confined to the (sub)figure box. It does not take into account any other artists. Parameters ---------- wrap : bool Notes ----- Wrapping does not work together with ``savefig(..., bbox_inches='tight')`` (which is also used internally by ``%matplotlib inline`` in IPython/Jupyter). The 'tight' setting rescales the canvas to accommodate all content and happens before wrapping. NrF)rlrts r9rz Text.set_wrap^s & r;c|jj|j\}}|jj }|j }|j d|j}|j||||}|jd|zdz|||}|dk(r|}|S|dk(r|}|Sdt||z}|S)zk Return the maximum line width for wrapping text based on the current orientation. rhrorr) rr get_positionrrget_horizontalalignmentrr_get_dist_to_boxr) rlrr figure_box alignmentrpror line_widths r9_get_wrap_line_widthzText._get_wrap_line_widthss ##%//0A0A0CDB__&88: 002  x($$&$$Xr2zB%% 8^s "BJ8  J  ' !JSu--Jr;c|dkDrz|dz }||jz tjtj|z }|j|z tjtjd|z z }no|dkDry|dz }||j z tjtj|z }||jz tjtjd|z z }n|dkDry|dz }|j |z tjtj|z }||j z tjtjd|z z }ns|j|z tjtj|z }|j |z tjtjd|z z }t||S)zr Return the distance from the given points to the boundaries of a rotated box, in pixels. iZrL)rmathcosradiansrrrr)rlrprrrQquadh1h2s r9rPzText._get_dist_to_boxsx c>c>Dz}}$d1C(DDB--"$b4i1H(IIB ^c>Dz}}$d1C(DDBz}}$b4i1H(IIB ]b=D--"$d1C(DDBz}}$b4i1H(IIB--"$h1G(HHB--"$b8m1L(MMB2r{r;c t|j||jtj||j dj \}}}tj|S)zE Return the width of a given text string, in pixels. Tr) rDrget_fontpropertiesr is_math_textrrCrWceil)rlr r-r.r(s r9_get_rendered_text_widthzText._get_rendered_text_widthsZ / NND$"9"9";   t $ OOO & * *,1ayy|r;c ,|js|jS|jr|jS|j}g}|jj d}|D] }|j d}t |dkDs$t |dk(r!|j |jd>tdt |dzD]}dj|d|}|j|}||kDr0|j dj|d|dz ||dz d}n7|t |k(sl|j dj|d|g}nt |dkDrdj|S)z Return a copy of the text string with new lines added so that the text is wrapped relative to the parent figure (if `get_wrap` is True). r rrrN) rHget_textrrTrlenrrrangejoinra) rlrS wrapped_linesunwrapped_linesunwrapped_line sub_wordsrr current_widths r9rzText._get_wrapped_texts }}==? " ?? ==? "..0  --///5. N&,,S1Ii.1$y>Q&!((q)9:q#i.1"45A88IbqM2D$($A$A$$GM%z1%,,SXXiQ6G-HI$-a!ef$5 c)n,%,,SXXim-DE$& ! i.1$  8yy''r;c |||_|jsy|jdk(ry|jd|j |j |j 5|j|\}}}|j}|j|j}}tjj|rtj}tjj|rtj}t|j!|}t|j#|} |j%|| f\}} tj&|stj&| r dddytj(|rtj(| st*j-d dddy|j/\} } |j0r,|j3||j0j5||j7} | j9|j;| j=|j?| jA|jB| jE|jF|jI| |jK} |D]\}}}}tM|dk(r|nd}||z}|| z}|jOr| |z }|jQ|\}}|jSrddl*m+}||jS|}n|}|jYr#|j[| ||||j\| ||j_| ||||j\| ||  ddd ja|jcdd |_2y#1swY2xYw) Nryr )r z%posx and posy should be finite valuesrr)PathEffectRenderer)mtext)rBroF)3rrrd open_groupget_gid_cm_setrrrrhrirrU is_maskednanr)r*r+risnanisfinite_logwarningget_canvas_width_heightrr4drawnew_gcset_foreground get_color set_alpha get_alphaset_url_urlrr _set_gc_cliprreflipyrget_path_effectsmatplotlib.patheffectsrnrdraw_texr draw_textrestore close_groupr)rlr!rinfortransr+r,r1r2canvaswcanvashgcanglerr*rorrBrn textrenderers r9rzz Text.drawsF  %DN!  ==?b FDLLN3 \\t557\ 8; G"&"2"28"< D$&&(E77DGGqAuuq!FFuuq!FF,,Q/0D,,Q/0D$6JD$xx~$; G; G ;;t$BKK,= DE%; G; G& (??A GW..x8  %%h/"B   dnn. / LL) * JJtyy !   t00 1   b !%%'E"& Gb!Q #D QDHH>>#! A%)%:%:4%@" F((*I#5--/$;L$,L??$ ))"aJ*.*>*>05*7!**2q!Z+/+?+?28+G+ GI; Gz V$ ; G; Gs/DO  AO GO  Oc|jS)zReturn the color of the text.)rrks r9r}zText.get_color0s {{r;c|jS)z*Return the `.font_manager.FontProperties`.)rrks r9r^zText.get_fontproperties4s###r;c6|jjS)z Return the list of font families used for font lookup. See Also -------- .font_manager.FontProperties.get_family )r get_familyrks r9get_fontfamilyzText.get_fontfamily8##..00r;c6|jjS)z Return the font name as a string. See Also -------- .font_manager.FontProperties.get_name )rget_namerks r9 get_fontnamezText.get_fontnameBs##,,..r;c6|jjS)z Return the font style as a string. See Also -------- .font_manager.FontProperties.get_style )r get_stylerks r9 get_fontstylezText.get_fontstyleLs##--//r;c6|jjS)z Return the font size as an integer. See Also -------- .font_manager.FontProperties.get_size_in_points )rget_size_in_pointsrks r9 get_fontsizezText.get_fontsizeVs##6688r;c6|jjS)z Return the font variant as a string. See Also -------- .font_manager.FontProperties.get_variant )r get_variantrks r9get_fontvariantzText.get_fontvariant`##//11r;c6|jjS)z Return the font weight as a string or a number. See Also -------- .font_manager.FontProperties.get_weight )r get_weightrks r9get_fontweightzText.get_fontweightjrr;c6|jjS)z Return the font stretch as a string or a number. See Also -------- .font_manager.FontProperties.get_stretch )r get_stretchrks r9rzText.get_stretchtrr;c|jS)zs Return the horizontal alignment as a string. Will be one of 'left', 'center' or 'right'. )rrks r9rOzText.get_horizontalalignment~s (((r;ct|j|j}t|j|j}||fS)z0Return the (x, y) unitless position of the text.)r)r*rhr+rirs r9rzText.get_unitless_positions? $%%dgg. / $%%dgg. /!t r;c2|j|jfS)z'Return the (x, y) position of the text.)rhrirks r9rNzText.get_positionswwr;c|jS)zReturn the text string.)rjrks r9rdz Text.get_textrIr;c|jS)z Return the vertical alignment as a string. Will be one of 'top', 'center', 'bottom', 'baseline' or 'center_baseline'. )rrks r9get_verticalalignmentzText.get_verticalalignments &&&r;c|jstjS|jd}| |j}|j dk(rLt j||5|j\}}tj||ddcdddS|||_ |j|j|_ |j tdt j||5|j|j\}}}|j\} } |jj!| | f\} } |j#| | }|cdddS#1swYxYw#1swYyxYw)a Return the `.Bbox` bounding the text, in display units. In addition to being used internally, this is useful for specifying clickable regions in a png file on a web page. Parameters ---------- renderer : Renderer, optional A renderer is needed to compute the bounding box. If the artist has already been drawn, the renderer is cached; thus, it is only necessary to pass this argument when calling `get_window_extent` before the first draw. In practice, it is usually easier to trigger a draw first, e.g. by calling `~.Figure.draw_without_rendering` or ``plt.show()``. dpi : float, optional The dpi value for computing the bbox, defaults to ``self.get_figure(root=True).dpi`` (*not* the renderer dpi); should be set e.g. if to match regions with a figure saved with a custom dpi value. TrNry)rCrzoCannot get window extent of text w/o renderer. You likely want to call 'figure.draw_without_rendering()' first.)rrunitrrCrdr _setattr_cmrrr _get_renderer RuntimeErrorrrrr translated) rlr!rCfigtxtyrrrr+r,s r9rzText.get_window_extentsm,!99; oo4o( ;''C ==?b ""3C0 6--/B''B15 6 6  %DN >> ! ..0DN >> !HI I  s , "&"2"24>>"B D$--/DAq%%'111a&9DAq??1a(D    6 6  s/+E0`. See Also -------- get_math_fontfamily N)rset_math_fontfamily)rlrXs r9rzText.set_math_fontfamilyrs( 00<< 6DL  Return whether mathtext parsing is considered for this `Text`.)rrks r9rzText.get_parse_mathQsr;c&|j|y)a1 Alias for `set_fontfamily`. One-way alias only: the getter differs. Parameters ---------- fontname : {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} See Also -------- .font_manager.FontProperties.set_family N)rrs r9 set_fontnamezText.set_fontnameUs H%r;)rrry)ryNNNNFrnroNNFNNNrFNN)U__name__ __module__ __qualname____doc__zorderrrrmr{r|r}rrrrrrrrrrrrrrr'r4r#r>r@rCrHrrTrPrarrallow_rasterizationrzr}r^rrrrrrrrOrrNrdrrrrrrrrrrrrrrrrrrrrrrrrr kwarg_docrrrrr __classcell__rs@r9rcrcPs L FfO=!#3#-%+ $ $!#(- !3n $"$#?J  .6- 5@", &#"! VDp&'P C./' ' ' *4. 1(f K KZ$1/09212) '/b(   0  $ :=,""   *  "00 Z<= >  , &r;rcc*eZdZdZddZdZdZdZy) OffsetFromz4Callable helper class for working with `Annotation`.cP||_|\}}||f|_|j|y)at Parameters ---------- artist : `~matplotlib.artist.Artist` or `.BboxBase` or `.Transform` The object to compute the offset from. ref_coord : (float, float) If *artist* is an `.Artist` or `.BboxBase`, this values is the location to of the offset origin in fractions of the *artist* bounding box. If *artist* is a transform, the offset origin is the transform applied to this value. unit : {'points, 'pixels'}, default: 'points' The screen units to use (pixels or points) for the offset input. N)_artist _ref_coordset_unit)rlr ref_coordrr+r,s r9r{zOffsetFrom.__init__ks+$ 1Q$ dr;cDtjddg|||_y)z Set the unit for input to the transform used by ``__call__``. Parameters ---------- unit : {'points', 'pixels'} pointspixels)rN)rr_unit)rlrs r9rzOffsetFrom.set_units  Hh/d; r;c|jS)z@Return the unit for input to the transform used by ``__call__``.)rrks r9get_unitzOffsetFrom.get_unitrIr;cTt|jtrc|jj|}|j\}}|j |j |zz}|j|j|zz}nt|jtrT|j}|j\}}|j |j |zz}|j|j|zz}nst|jtr)|jj|j\}}n0tjtttf|j|jdk(rdn|jd}t!j#|j%S)aL Return the offset transform. Parameters ---------- renderer : `RendererBase` The renderer to use to compute the offset Returns ------- `Transform` Maps (x, y) in pixel or point units to screen units relative to the given artist. )rrr)r"rr rrrrrrrrrrrrr/rscaler.)rlr!rxfyfr+r,rs r9__call__zOffsetFrom.__call__s3 dllF +<<11(;D__FB$**r/)A$++**A  h /<. 7r;rcFeZdZ d dZdZdZdZdZdZd dZ d d Z y) _AnnotationBaseNc^|\}}||f|_||_|j|d|_yrF)rxycoordsset_annotation_clip _draggable)rlrr%annotation_clipr+r,s r9r{z_AnnotationBase.__init__s4 1Q$     1r;c|\}}t|tr|n||f\}}|dk(rt|j|}|dk(rt|j |}|j ||j ||fS)Ndata)r"tupler)r*r+_get_xy_transformr)rlr!rcoordsr+r,xcoordycoords r9_get_xyz_AnnotationBase._get_xys1#-fe#<66BR V d))!,-A V d))!,-A%%h7AA1a&IIr;cXt|tr8|\}}ddlm}|j ||}|j ||}|||St |rV||}t|t r t|St|tr|Stdt|jt|tr|j|} t| St|t r t|St|tr|St|ts!tdt|j|dk(r|jj S|dk(r3ddlm} | j'd }||jj z} | S |j)\} } d \}}| d k(r|j-d j.}n=| dk(r|j-d j0}n| dk(r|jj0}| |j2}n%| dk(r|j5|}nt+|d | dk(r7t7j9|j-d j:dz }n| dk(r t7}n| dk(rHt7j9|j=|j-d j:zdz }n5| dk(r"t7j8|j>}nt+| d|j@|S#t*$rt+|d dwxYw)Nr)blended_transform_factoryz=xycoords callable must return a BboxBase or Transform, not a z^'xycoords' must be an instance of str, tuple[str, str], Artist, Transform, or Callable, not a r*polar) PolarAxesF)apply_theta_transformsz is not a valid coordinaterfigurer subfigureaxesoffsetrTHrrZfractionz is not a recognized unit)!r"r+matplotlib.transformsr2r,callablerrr TypeErrortyperr rrr8 transDatamatplotlib.projectionsr4PolarTransformrrrfigbboxrp0_get_position_xyrrrCr!rNr.)rlr!r-r.r/r2tr1tr2r%rr4r bbox_namerbbox0xy0s r9r,z!_AnnotationBase._get_xy_transforms fe $#NFF G((6:C((6:C,S#6 6 f !B"h'&r**B * SBx(()+,, '++H5D"4( (  )"6* *  *MFC(115f1F1F0GIJ J V 99&& & w  8)))GB,,,EL P$llnOIt s  OOO/77E + %OOO/44E & IINNE  ((C ( "''1Cz)CDE E 8 !!T*..35B X B Z !! $//t/"<"@"@@2EGB Z !!!5::.Bx'@AB Br||S!!E Pz)CDE4 O Ps LL)c||_y)a Set the annotation's clipping behavior. Parameters ---------- b : bool or None - True: The annotation will be clipped when ``self.xy`` is outside the Axes. - False: The annotation will always be drawn. - None: The annotation will be clipped when ``self.xy`` is outside the Axes and ``self.xycoords == "data"``. N_annotation_clip)rlrDs r9r&z#_AnnotationBase.set_annotation_clips !"r;c|jS)z Return the annotation's clipping behavior. See `set_annotation_clip` for the meaning of return values. rLrks r9get_annotation_clipz#_AnnotationBase.get_annotation_clip#s $$$r;cP|j||j|jS)z1Return the pixel position of the annotated point.)r0rr%)rlr!s r9rEz _AnnotationBase._get_position_xy+s||Hdggt}}==r;c| |jdj}|j}|s|;|jdk(r,|j |}|j j |Sy)z;Check whether the annotation at *xy_pixel* should be drawn.Trr*)rrrOr%rEr8contains_point)rlr!rDxy_pixels r9 _check_xyz_AnnotationBase._check_xy/si  D1??AH  $ $ & t}}6,,X6H99++H5 5r;cddlm}|jdu}|| }|r&|j||||_|jS|j|jjd|_|jS)a9 Set whether the annotation is draggable with the mouse. Parameters ---------- state : bool or None - True or False: set the draggability. - None: toggle the draggability. use_blit : bool, default: False Use blitting for faster image composition. For details see :ref:`func-animation`. Returns ------- DraggableAnnotation or None If the annotation is draggable, the corresponding `.DraggableAnnotation` helper is returned. r)DraggableAnnotationN)matplotlib.offsetboxrVr' disconnect)rlstateuse_blitrV is_draggables r9 draggablez_AnnotationBase.draggable:sx& =d2  =$$E &"5dH"E  ***,"DOr;)r*NrFNF) rrrr{r0r,r&rOrErTr\r!r;r9r#r#s5!!% JJ"X "%> "r;r#ceZdZdZdZ ddZdZedZejdZedZ e jdZ d Z d Z ee e d Z d ZdZej"dZddZdfd ZxZS) Annotationa` An `.Annotation` is a `.Text` that can refer to a specific position *xy*. Optionally an arrow pointing from the text to *xy* can be drawn. Attributes ---------- xy The annotated position. xycoords The coordinate system for *xy*. arrow_patch A `.FancyArrowPatch` to point from *xytext* to *xy*. cfd|jddd|jddd|jdS)Nz Annotation(rgrfrrg)rrjrks r9__str__zAnnotation.__str__ns5TWWQZN"TWWQZN"TZZN!LLr;c tj||||||||k7rtjd| |j}||_| |j }|\} } ||_|V|j}d|vr|jdd|_ ndD]} |j| dtdi||_ nd|_ tj|| | |fi|y) a Annotate the point *xy* with text *text*. In the simplest form, the text is placed at *xy*. Optionally, the text can be displayed in another position *xytext*. An arrow pointing from the text to the annotated point *xy* can then be added by defining *arrowprops*. Parameters ---------- text : str The text of the annotation. xy : (float, float) The point *(x, y)* to annotate. The coordinate system is determined by *xycoords*. xytext : (float, float), default: *xy* The position *(x, y)* to place the text at. The coordinate system is determined by *textcoords*. xycoords : single or two-tuple of str or `.Artist` or `.Transform` or callable, default: 'data' The coordinate system that *xy* is given in. The following types of values are supported: - One of the following strings: ==================== ============================================ Value Description ==================== ============================================ 'figure points' Points from the lower left of the figure 'figure pixels' Pixels from the lower left of the figure 'figure fraction' Fraction of figure from lower left 'subfigure points' Points from the lower left of the subfigure 'subfigure pixels' Pixels from the lower left of the subfigure 'subfigure fraction' Fraction of subfigure from lower left 'axes points' Points from lower left corner of the Axes 'axes pixels' Pixels from lower left corner of the Axes 'axes fraction' Fraction of Axes from lower left 'data' Use the coordinate system of the object being annotated (default) 'polar' *(theta, r)* if not native 'data' coordinates ==================== ============================================ Note that 'subfigure pixels' and 'figure pixels' are the same for the parent figure, so users who want code that is usable in a subfigure can use 'subfigure pixels'. - An `.Artist`: *xy* is interpreted as a fraction of the artist's `~matplotlib.transforms.Bbox`. E.g. *(0, 0)* would be the lower left corner of the bounding box and *(0.5, 1)* would be the center top of the bounding box. - A `.Transform` to transform *xy* to screen coordinates. - A function with one of the following signatures:: def transform(renderer) -> Bbox def transform(renderer) -> Transform where *renderer* is a `.RendererBase` subclass. The result of the function is interpreted like the `.Artist` and `.Transform` cases above. - A tuple *(xcoords, ycoords)* specifying separate coordinate systems for *x* and *y*. *xcoords* and *ycoords* must each be of one of the above described types. See :ref:`plotting-guide-annotation` for more details. textcoords : single or two-tuple of str or `.Artist` or `.Transform` or callable, default: value of *xycoords* The coordinate system that *xytext* is given in. All *xycoords* values are valid as well as the following strings: ================= ================================================= Value Description ================= ================================================= 'offset points' Offset, in points, from the *xy* value 'offset pixels' Offset, in pixels, from the *xy* value 'offset fontsize' Offset, relative to fontsize, from the *xy* value ================= ================================================= arrowprops : dict, optional The properties used to draw a `.FancyArrowPatch` arrow between the positions *xy* and *xytext*. Defaults to None, i.e. no arrow is drawn. For historical reasons there are two different ways to specify arrows, "simple" and "fancy": **Simple arrow:** If *arrowprops* does not contain the key 'arrowstyle' the allowed keys are: ========== ================================================= Key Description ========== ================================================= width The width of the arrow in points headwidth The width of the base of the arrow head in points headlength The length of the arrow head in points shrink Fraction of total length to shrink from both ends ? Any `.FancyArrowPatch` property ========== ================================================= The arrow is attached to the edge of the text box, the exact position (corners or centers) depending on where it's pointing to. **Fancy arrow:** This is used if 'arrowstyle' is provided in the *arrowprops*. Valid keys are the following `.FancyArrowPatch` parameters: =============== =================================== Key Description =============== =================================== arrowstyle The arrow style connectionstyle The connection style relpos See below; default is (0.5, 0.5) patchA Default is bounding box of the text patchB Default is None shrinkA In points. Default is 2 points shrinkB In points. Default is 2 points mutation_scale Default is text size (in points) mutation_aspect Default is 1 ? Any `.FancyArrowPatch` property =============== =================================== The exact starting point position of the arrow is defined by *relpos*. It's a tuple of relative coordinates of the text box, where (0, 0) is the lower left corner and (1, 1) is the upper right corner. Values <0 and >1 are supported and specify points outside the text box. By default (0.5, 0.5), so the starting point is centered in the text box. annotation_clip : bool or None, default: None Whether to clip (i.e. not draw) the annotation when the annotation point *xy* is outside the Axes area. - If *True*, the annotation will be clipped when *xy* is outside the Axes. - If *False*, the annotation will always be drawn. - If *None*, the annotation will be clipped when *xy* is outside the Axes and *xycoords* is 'data'. **kwargs Additional kwargs are passed to `.Text`. Returns ------- `.Annotation` See Also -------- :ref:`annotations` )r%r(NzgYou have used the `textcoords` kwarg, but not the `xytext` kwarg. This can lead to surprising results. arrowstylerelpos)?rf)r headwidth headlengthshrink)r )rr)r#r{r warn_externalr% _textcoordsr arrowpropsr@r _arrow_relposr arrow_patchrc) rlr rxytextr% textcoordsrlr(r~r+r,keys r9r{zAnnotation.__init__qsX   !#*21@ ! B N&h&    5 6  J% >WWF1$  !#*Jz)%/^^Hj%I"J.CNN3-..LLD #D  dAq$1&1r;c|j|rdifStj||\}}|j$|jj|\}}|xs|}||fSr])rrcrrn)rlrrtinfoin_patchr&s r9rzAnnotation.containsCsh  ! !* -"9 --j9%    '**33J?KHa+8Hr;c|jSrF) _xycoordsrks r9r%zAnnotation.xycoordsLs ~~r;cd}t|trtt||s||r t d||_y)NcHt|txr|jdS)Nr9)r"r startswith)rs r9 is_offsetz&Annotation.xycoords..is_offsetRsa%@!,,x*@ @r;z'xycoords cannot be an offset coordinate)r"r+anymaprrv)rlr%rzs r9r%zAnnotation.xycoordsPs= A x 'CIx0H,IX&FG G!r;c"|jS)zQ The text position. See also *xytext* in `.Annotation`. )rNrks r9xyannzAnnotation.xyannZs  ""r;c&|j|yrF)r)rlros r9r~zAnnotation.xyanncs &!r;c|jS)z} Return the coordinate system to use for `.Annotation.xyann`. See also *xycoords* in `.Annotation`. rkrks r9 get_anncoordszAnnotation.get_anncoordsgs r;c||_y)zz Set the coordinate system to use for `.Annotation.xyann`. See also *xycoords* in `.Annotation`. Nr)rlr-s r9 set_anncoordszAnnotation.set_anncoordsos "r;z> The coordinate system to use for `.Annotation.xyann`.)docc~|j|jj|tj||yrF)rn set_figurer )rlrs r9rzAnnotation.set_figurezs2    '    ' ' ,$$r;c,|j|j||j|j}|ytj ||}|j |x}\|jd|j}|jj|d|vrq|jdd}|jdd}|jdd }|jd d } t| |z ||z ||z } |jjdi| |jd f|j|jzd z df|jdfg} |jd f|j|j zd z df|j dfg} t#| fd\} }t#| fd\}}||f|_t'j(|z | z }||z|j+dz }|x|j_|j_|j0|j2|j$zz}|jj5||d|vr|d}n|j6r |j6}n{|j9dk(rd}ne|j+d}t;|j|d z z |j|d z z f|j<|z|j>|ztAd}|jjC|y)zX Update the pixel positions of the annotation text and the arrow patch. Nmutation_scalerdrirrrrg rh) head_length head_width tail_widthrrrfrc&t|dz SNrr)vrs r9z-Annotation.update_positions..QqTBYr;)rqc&t|dz Srr)rrs r9rz-Annotation.update_positions..rr;patchAryF)rrrrr8)simple)"r-r, anncoordsrlrcrrEgetr!rnr0rset_arrowstylerrrrrrmrhypotr/shrinkAshrinkBrDrN set_positionsrrdr rrr set_patchA)rlr!rlr arrow_endmsrirrgrhstylekwxposyposr+relposxr,relposyr shrink_pts arrow_beginrrrrs @@r9update_positionszAnnotation.update_positionss 411(DNNKL__   %%dH5!228<< FB ^^,dmmo > ++B/ z )^^Hc2FNN7A.E"{B7I# b9JzB&/"n&+bj2G ,D   + + @ @WWaLDGGdgg$5#:C"@477A,ODWWaLDGGdgg$5#:C"@477A,ODT'?@JAwT'?@JAw")7!3D RR(A!h&?&?&BBJBL LD   $t'7'7'?gg D,>,> >>  &&{I> z !)F   %%F ]]_ "F++A.CGGcAg%twwq'89jj3&t{{S/@+-u>F ##F+r;c|||_|jr|j|sy|j||j ||j f|j j d/|j dx}|j j||j j|tj||y)NFr) rrrTrr4rnrrrzrc)rlr!rs r9rzzAnnotation.draws  %DN!)A  h' &&x0    '  +++7? OOO77SD  ++C0    ! !( + $!r;c|jr|j|stjS|||_|j%|j dj |_|j td|j|jtj|}|g}|j)|j|jjtj|S)NTrz)Cannot get window extent without renderer)rrTrrrrrrrrcrrnrunion)rlr! text_bboxbboxess r9rzAnnotation.get_window_extents!)A99;   %DN >> !!__$_7EEGDN >> !JK K dnn-**40     ' MM$**<<> ?zz&!!r;cl|j|stjSt||SrF)rTrnullrz get_tightbbox)rlr!rs r9rzAnnotation.get_tightbboxs+~~h'99; w$X..r;)Nr*NNNrF)rrrr rbr{rpropertyr%setterr~rrrrrrr rzrrr rs@r9r_r__s M   !% P2d__""## \\"" " numpyr matplotlibrryrrrrr font_managerr patchesr r r textpathrr transformsrrrrrr getLoggerrrwr:rD lru_cacher=interpddefine_aliasesrcrr#r_registerr{r!r;r9rsT --(??*MMw"$&NCTPP  U01*;;* 6f  F&6F& F&R(G7G7TjjZQ/Q/h  z':':'B'BCr;