rL i/(dZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z ddlmZmZddlmZddlmZddlmZddlmZmZmZmZmZdd lmZmZm Z m!Z!m"Z"m#Z#dd l$m%Z%dd l&m'Z'm(Z(m)Z)dd l&m*Z*m+Z+dd l,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4m5Z5m6Z6ddl7m8Z8Gdde.Z9dZ:dZ;dZe j~je>dZAe;j{dddeAe:zZBe j~jeBe;j{dd e`. The `Legend` class is a container of legend handles and legend texts. The legend handler map specifies how to create legend handles from artists (lines, patches, etc.) in the Axes or figures. Default legend handlers are defined in the :mod:`~matplotlib.legend_handler` module. While not all artist types are covered by the default legend handlers, custom legend handlers can be defined to support arbitrary objects. See the :ref`` for more information. N)_api _docstringcbookcolors offsetbox)Artistallow_rasterization) silent_list)FontProperties)Line2D)Patch RectangleShadowFancyBboxPatch StepPatch) CollectionCircleCollectionLineCollectionPathCollectionPolyCollectionRegularPolyCollection)Text)BboxBboxBaseTransformedBbox)BboxTransformToBboxTransformFrom)AnchoredOffsetboxDraggableOffsetBoxHPackerVPacker DrawingAreaTextArea)ErrorbarContainer BarContainer StemContainer)legend_handlerc2eZdZdfd ZdZdZdZxZS)DraggableLegendc||_tjddg|||_t|||j |y)a Wrapper around a `.Legend` to support mouse dragging. Parameters ---------- legend : `.Legend` The `.Legend` instance to wrap. use_blit : bool, optional Use blitting for faster image composition. For details see :ref:`func-animation`. update : {'loc', 'bbox'}, optional If "loc", update the *loc* parameter of the legend upon finalizing. If "bbox", update the *bbox_to_anchor* parameter. locbboxupdate)use_blitN)legendr check_in_list_updatesuper__init__ _legend_box)selfr1r0r/ __class__s W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/legend.pyr5zDraggableLegend.__init__7sA  E6?6:  !3!3hGc|jdk(r |j|jy|jdk(r |j|jyy)Nr,r-)r3 _update_locget_loc_in_canvas_update_bbox_to_anchorr7s r9finalize_offsetzDraggableLegend.finalize_offsetMsM <<5   T335 6 \\V #  ' '(>(>(@ A$r:cF|jj}|jdk(s|jdk(r5|jj d|jj}t |}t |j||j_y)Nr) r1get_bbox_to_anchorwidthheightset_bbox_to_anchorrtuple transform_loc)r7 loc_in_canvasr-_bbox_transforms r9r<zDraggableLegend._update_locSsv{{--/ ::?dkkQ. KK * *4 0;;113D+D1 !:!:=!IJ r:c|jjjj|}|jj |yN)r1axes transAxesrGrE)r7rI loc_in_bboxs r9r>z&DraggableLegend._update_bbox_to_anchor]s4kk&&00::=I  &&{3r:Fr,)__name__ __module__ __qualname__r5r@r<r> __classcell__r8s@r9r*r*6sH,B K4r:r*a9 bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats Box that is used to position the legend in conjunction with *loc*. Defaults to ``axes.bbox`` (if called as a method to `.Axes.legend`) or ``figure.bbox`` (if ``figure.legend``). This argument allows arbitrary placement of the legend. Bbox coordinates are interpreted in the coordinate system given by *bbox_transform*, with the default transform Axes or Figure coordinates, depending on which ``legend`` is called. If a 4-tuple or `.BboxBase` is given, then it specifies the bbox ``(x, y, width, height)`` that the legend is placed in. To put the legend in the best location in the bottom right quadrant of the Axes (or figure):: loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5) A 2-tuple ``(x, y)`` places the corner of the legend specified by *loc* at x, y. For example, to put the legend's upper right-hand corner in the center of the Axes (or figure) the following keywords can be used:: loc='upper right', bbox_to_anchor=(0.5, 0.5) ncols : int, default: 1 The number of columns that the legend has. For backward compatibility, the spelling *ncol* is also supported but it is discouraged. If both are given, *ncols* takes precedence. prop : None or `~matplotlib.font_manager.FontProperties` or dict The font properties of the legend. If None (default), the current :data:`matplotlib.rcParams` will be used. fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} The font size of the legend. If the value is numeric the size will be the absolute font size in points. String values are relative to the current default font size. This argument is only used if *prop* is not specified. labelcolor : str or list, default: :rc:`legend.labelcolor` The color of the text in the legend. Either a valid color string (for example, 'red'), or a list of color strings. The labelcolor can also be made to match the color of the line or marker using 'linecolor', 'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec'). Labelcolor can be set globally using :rc:`legend.labelcolor`. If None, use :rc:`text.color`. numpoints : int, default: :rc:`legend.numpoints` The number of marker points in the legend when creating a legend entry for a `.Line2D` (line). scatterpoints : int, default: :rc:`legend.scatterpoints` The number of marker points in the legend when creating a legend entry for a `.PathCollection` (scatter plot). scatteryoffsets : iterable of floats, default: ``[0.375, 0.5, 0.3125]`` The vertical offset (relative to the font size) for the markers created for a scatter plot legend entry. 0.0 is at the base the legend text, and 1.0 is at the top. To draw all markers at the same height, set to ``[0.5]``. markerscale : float, default: :rc:`legend.markerscale` The relative size of legend markers compared to the originally drawn ones. markerfirst : bool, default: True If *True*, legend marker is placed to the left of the legend label. If *False*, legend marker is placed to the right of the legend label. reverse : bool, default: False If *True*, the legend labels are displayed in reverse order from the input. If *False*, the legend labels are displayed in the same order as the input. .. versionadded:: 3.7 frameon : bool, default: :rc:`legend.frameon` Whether the legend should be drawn on a patch (frame). fancybox : bool, default: :rc:`legend.fancybox` Whether round edges should be enabled around the `.FancyBboxPatch` which makes up the legend's background. shadow : None, bool or dict, default: :rc:`legend.shadow` Whether to draw a shadow behind the legend. The shadow can be configured using `.Patch` keywords. Customization via :rc:`legend.shadow` is currently not supported. framealpha : float, default: :rc:`legend.framealpha` The alpha transparency of the legend's background. If *shadow* is activated and *framealpha* is ``None``, the default value is ignored. facecolor : "inherit" or color, default: :rc:`legend.facecolor` The legend's background color. If ``"inherit"``, use :rc:`axes.facecolor`. edgecolor : "inherit" or color, default: :rc:`legend.edgecolor` The legend's background patch edge color. If ``"inherit"``, use :rc:`axes.edgecolor`. mode : {"expand", None} If *mode* is set to ``"expand"`` the legend will be horizontally expanded to fill the Axes area (or *bbox_to_anchor* if defines the legend's size). bbox_transform : None or `~matplotlib.transforms.Transform` The transform for the bounding box (*bbox_to_anchor*). For a value of ``None`` (default) the Axes' :data:`~matplotlib.axes.Axes.transAxes` transform will be used. title : str or None The legend's title. Default is no title (``None``). title_fontproperties : None or `~matplotlib.font_manager.FontProperties` or dict The font properties of the legend's title. If None (default), the *title_fontsize* argument will be used if present; if *title_fontsize* is also None, the current :rc:`legend.title_fontsize` will be used. title_fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}, default: :rc:`legend.title_fontsize` The font size of the legend's title. Note: This cannot be combined with *title_fontproperties*. If you want to set the fontsize alongside other font properties, use the *size* parameter in *title_fontproperties*. alignment : {'center', 'left', 'right'}, default: 'center' The alignment of the legend title and the box of entries. The entries are aligned as a single block, so that markers always lined up. borderpad : float, default: :rc:`legend.borderpad` The fractional whitespace inside the legend border, in font-size units. labelspacing : float, default: :rc:`legend.labelspacing` The vertical space between the legend entries, in font-size units. handlelength : float, default: :rc:`legend.handlelength` The length of the legend handles, in font-size units. handleheight : float, default: :rc:`legend.handleheight` The height of the legend handles, in font-size units. handletextpad : float, default: :rc:`legend.handletextpad` The pad between the legend handle and text, in font-size units. borderaxespad : float, default: :rc:`legend.borderaxespad` The pad between the Axes and legend border, in font-size units. columnspacing : float, default: :rc:`legend.columnspacing` The spacing between columns, in font-size units. handler_map : dict or None The custom dictionary mapping instances or types to a legend handler. This *handler_map* updates the default handler map found at `matplotlib.legend.Legend.get_legend_handler_map`. draggable : bool, default: False Whether the legend can be dragged with the mouse. a4 loc : str or pair of floats, default: {default} The location of the legend. The strings ``'upper left'``, ``'upper right'``, ``'lower left'``, ``'lower right'`` place the legend at the corresponding corner of the {parent}. The strings ``'upper center'``, ``'lower center'``, ``'center left'``, ``'center right'`` place the legend at the center of the corresponding edge of the {parent}. The string ``'center'`` places the legend at the center of the {parent}. {best} The location can also be a 2-tuple giving the coordinates of the lower-left corner of the legend in {parent} coordinates (in which case *bbox_to_anchor* will be ignored). For back-compatibility, ``'center right'`` (but no other location) can also be spelled ``'right'``, and each "string" location can also be given as a numeric value: ================== ============= Location String Location Code ================== ============= 'best' (Axes only) 0 'upper right' 1 'upper left' 2 'lower left' 3 'lower right' 4 'right' 5 'center left' 6 'center right' 7 'lower center' 8 'upper center' 9 'center' 10 ================== ============= {outside}a/ The string ``'best'`` places the legend at the location, among the nine locations defined so far, with the minimum overlap with other drawn artists. This option can be quite slow for plots with large amounts of data; your plotting speed may benefit from providing a specific location. rMz:rc:`legend.loc`)parentdefaultbestoutside)_legend_kw_axesaX If a figure is using the constrained layout manager, the string codes of the *loc* keyword argument can get better layout behaviour using the prefix 'outside'. There is ambiguity at the corners, so 'outside upper right' will make space for the legend above the rest of the axes in the layout, and 'outside right upper' will make space on the right side of the layout. In addition to the values of *loc* listed above, we have 'outside right upper', 'outside right lower', 'outside left upper', and 'outside left lower'. See :ref:`legend_guide` for more details. figurez 'upper right')_legend_kw_figurez axes/figurez3:rc:`legend.loc` for Axes, 'upper right' for Figure)_legend_kw_doc)_legend_kw_set_loc_docc$eZdZdZddiej ZdZdZejdddddddddddddddddd dddddddddddddd d dd "fd Z d Z ejd0dZ dZ dZdZeee ZdZedZeej.eej2eej6eej:eej>e ejBe"ejFe$ejJe&ej:ejNe(ejRe*ejVe,ejZi Z.e/dZ0e/dZ1e/dZ2dZ3e4dZ5d1dZ6dZ7dZ8dZ9dZ:dZ;d Zd0d#Z?d$Z@d0d%ZAd0d&ZBd'ZCd(ZDeDZEd)ZFd0d*ZGd+ZHd,ZId-ZJd2d.ZKd/ZLxZMS)3Legendz, Place a legend on the figure/axes. rYrcy)Nrar?s r9__str__zLegend.__str___sr:NTFr'center)"r, numpoints markerscale markerfirstreverse scatterpointsscatteryoffsetspropfontsize labelcolor borderpad labelspacing handlelength handleheight handletextpad borderaxespad columnspacingncolsmodefancyboxshadowtitletitle_fontsize framealpha edgecolor facecolorbbox_to_anchorbbox_transformframeon handler_maptitle_fontproperties alignmentncol draggablec">ddlm}&ddlm}'t0|| &t tj| d|_ nZt j| |_ t| tr0d| vr,|jjtjd|jj|_g|_g|_d|_|!|_tj|d|_tj|d |_tj| d |_tj|d |_tj|d |_tj|d |_tj|d|_tj|d|_tj|d|_tj|d|_tj|d|_|rgtA|}gtA|}tC|}tE|dkrd}|dk7r|n|$|_#|j*dkrtId|z| tKjLgd|_'ntKjP| |_'|j.tE|jNzdz}(tKjR|jN|(d|j.|_'d|_*t||&r0d|_+||_,|j[|j]dn0t||'rd|_+|j[|n t_d||_0||_1|je||ddd|_3t|j>tr-|jfji|j>d|_nX|j>dvrtk|j>|_n/tId|j>dtm|j>d tj|d!}|d"k(rtjd#}tj|d$}|d"k(rtjd%}tj|d&}tod'dd||||n|rdntjd(|rd)nd*|j dtj| d+, |_8|js|jptujvgd-|#.|#|_<|j{||||j}|| |" tId/t j|"})t|"tr)d|"vrmtjd0}|)j|nH||)j|n4t|"t s$tjd0}|)j||j||)1d|_@|j|%2d3d4gd5d4gd5d4gd6d7gd6d7gd8}*tj| d9} | tjd:} t| tr| |*vr|*| }+t|j$|j"D]\},}- |,j |+D]}. t|,|.}/t|/tJjrO|/jddk(s'tKj|/|/djr|-j|/dnn|-j|/ytj| d;r#|j"D]}-|-j| ytKj| rVt|j"tjtj| D]\}-}/|-j|/ytId<| #t$rYUwxYw#t$rYcwxYw)=a Parameters ---------- parent : `~matplotlib.axes.Axes` or `.Figure` The artist that contains the legend. handles : list of (`.Artist` or tuple of `.Artist`) A list of Artists (lines, patches) to be added to the legend. labels : list of str A list of labels to show next to the artists. The length of handles and labels should be the same. If they are not, they are truncated to the length of the shorter list. Other Parameters ---------------- %(_legend_kw_doc)s Attributes ---------- legend_handles List of `.Artist` objects added as legend entries. .. versionadded:: 3.7 r)Axes) FigureBaseNzlegend.fontsize)sizerzlegend.numpointszlegend.markerscalezlegend.scatterpointszlegend.borderpadzlegend.labelspacingzlegend.handlelengthzlegend.handleheightzlegend.handletextpadzlegend.borderaxespadzlegend.columnspacingz legend.shadowr'z numpoints must be > 0; it was %d)g?g?g?TFrootz0Legend needs either Axes or FigureBase as parent)oxoy)rr'TFz*Legend shadow must be a dict or bool, not z of type .zlegend.facecolorinheritzaxes.facecolorzlegend.edgecolorzaxes.edgecolorzlegend.fancybox)rrzlegend.framealphazround,pad=0,rounding_size=0.2z square,pad=0zlegend.frameon) xyrCrDrr~alphaboxstylemutation_scalesnapvisiblerfleftrightrzctitle_fontsize and title_fontproperties can't be specified at the same time. Only use one of them. zlegend.title_fontsize)rm)state get_color get_facecolorget_markerfacecolorget_markeredgecolor get_edgecolor) linecolormarkerfacecolormfcmarkeredgecolormeczlegend.labelcolorz text.colornonezInvalid labelcolor: )Smatplotlib.axesrmatplotlib.figurerr4r5r mpl _val_or_rcrm _from_any isinstancedictset_sizercParamsget_size_in_points _fontsizetextslegend_handles_legend_title_box_custom_handler_maprgrhrkrprqrrrsrtrurvrzreversedlistlen_ncols ValueErrornparray_scatteryoffsetsasarraytiler6isaxesrM set_figure get_figure TypeErrorrW_moderE _shadow_propsr/booltyper legendPatch_set_artist_propsrr2 _alignment_init_legend_boxset_loc set_title _draggable set_draggablestrzip get_arrayAttributeErrorgetattrndarrayshapeiscloseall set_colorr _str_equaliterable itertoolscycler to_rgba_array)1r7rWhandleslabelsr,rgrhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|r}r~rrrrrrrrrrrreps title_prop_fp color_getters getter_nameshandletext getter_namecolorr8s1 r9r5zLegend.__init__bs;L )0  <&CNN8EV,WXDI&006DI$%&*< ""3<<0A#BC557  !%$/  3EF>>+7KL ^^M;QR 3EFNN<9NONN<9NONN<9NO ^^M;QR ^^M;QR ^^M;QRnnV_= (x'(F*)*Gw- w>Q ?)KL L  "$&HH-I$JD !$&JJ$?D !!!S)>)>%??!C "(=(=(,!..At/A/A!C   fd #DKDI OOF--5-9 :  +DK OOF #B    ? %&R0 dkk4 (    % %dkk 2DK [[/ /t{{+DK<;;/4 +<*=Q@ NN9.@A  ! %56INN9.@A  ! %56I>>(,=>)Qq9!+!7:# %89:B5)>>NN7,<=  t//0 6)L# gv{; S  %*>*J;< <'001EF *D 111!$.E!F&&~6  '  " "> 20.A \\*ABN  " "> 2 u=1 + !,G 5G 5G 5G 5G  ^^J0CD  l3J j# &:+F(4L #D$7$7 D  '')5 6$0K < < >%eRZZ8$)KKNa$7')zz%q'B'F'F'H $uQx 8 $ NN51  ,  j& 1  +z* + [[ $"4::#,??'-';';J'G$I J & eu% & 3J>BC C7& *s%$_?loc must be string, coordinate tuple, or an integer 0-10, not rrZzoutside r'zcenter rV)rrrf )r,rc3PK|]}t|tj ywrL)rnumbersReal).0es r9 z!Legend.set_loc..s'Q 1gll(C'Qs$& z'outside' option for loc='z0' keyword argument only works for figure legendszIAutomatic legend placement (loc='best') not implemented for figure legend)_loc_used_defaultrrr _outside_locrrsplitreplacerr check_getitemcodesrrrFrrint_set_loc)r7r,loc0type_err_messagelocstmps r9rzLegend.set_locys!$ ;,,|,C;;3+#5#558G=! c3 yy{1~*ii +A.$'KK 2$>!$($5$5$;$;$=a$@!yy{t9q=T!W0A%AAw(*#DbDzq'C-$q'1C$$TZZS9C [[ *C3x1}C'QS'Q$Q !122 S !Qw#( !122-. . ;;4,,,TF3++, ,{{sax ! !$$ c!$r:cxd|_||_d|_|jj |j y)NFT)r _loc_realstaler6 set_offset _findoffset)r7r,s r9rzLegend._set_locs4"'  ##D$4$45r:c||_y)zSet the number of columns.N)r)r7rws r9 set_ncolszLegend.set_ncolss  r:c|jSrL)rr?s r9_get_loczLegend._get_locs ~~r:c|jdk(r|j|||\}}n|jtjj vrHt j dd||}|j|j||j|\}}nW|j\} } |j}|j|j| zz|j|j| zz}}||z||zfS)z%Helper function to locate the legend.r) rH_find_best_positionrarvaluesr from_bounds_get_anchored_bboxrBx0rCy0rD) r7rCrDxdescentydescentrendererxyr-fxfys r9r zLegend._findoffsets 99>++E68DDAq YY&,,--/ /##Aq%8D**499d+/+B+B+D+35DAqYYFB**,D77TZZ"_,dgg b8H.HqA8|Q\))r:c,|jsy|jd|j|j|j}|j dvrUd|j |jzz|z}|jj|jj|z |jj|}|jj|j|jj!||j"r/t%|jfi|j&j)||jj)||jj)||j+dd|_y)Nr1)gid)expandrF) get_visible open_groupget_gidpoints_to_pixelsrrrurpr6 set_widthrBrCget_window_extentr set_boundsboundsset_mutation_scalerzrrdraw close_groupr)r7rrnpadr-s r9r)z Legend.drawsB! H$,,.9,,T^^< :: #t))DNN:;hFC    & &t'>'>'@'F'F'L M11(; ##DKK0 ++H5 ;; 4## :t'9'9 : ? ? I h' h'X& r:) update_funcc|jS)z=Return the global default handler map, shared by all legends._default_handler_map)clss r9get_default_handler_mapzLegend.get_default_handler_maps'''r:c||_y)z:Set the global default handler map, shared by all legends.Nr.r0rs r9set_default_handler_mapzLegend.set_default_handler_maps $/ r:c:|jj|y)z=Update the global default handler map, shared by all legends.N)r/r/r3s r9update_default_handler_mapz!Legend.update_default_handler_map!s   '' 4r:c^|j}|jri||jS|S)z*Return this legend instance's handler map.)r1r)r7default_handler_maps r9get_legend_handler_mapzLegend.get_legend_handler_map&s@"::<++D&C$*B*BC F1D Fr:c ||S#ttf$rYnwxYwt|jD]} ||cS#t$rYwxYwy)a Return a legend handler from *legend_handler_map* that corresponds to *orig_handler*. *legend_handler_map* should be a dictionary object (that is returned by the get_legend_handler_map method). It first checks if the *orig_handle* itself is a key in the *legend_handler_map* and return the associated value. Otherwise, it checks for each of the classes in its method-resolution-order. If no matching key is found, it returns ``None``. N)rKeyErrorrmro)legend_handler_map orig_handle handle_types r9get_legend_handlerzLegend.get_legend_handler,sm %k2 28$    ,002 K )+66    sA A  A c |j}g}g}g}d|z|jdz z}||jz|z } |j} t||D]\} } |j | | } | >t j dt| jd|jdXt| dtdd|j  }t|j|z| d | }|j|j|j| j!|| |||j||fg}t#t$t'j(||j*D]i}|Dcgc])\}}t-d |j.|z|r||gn||gd+}}}|rdnd}|jt1d |j2|z||k|j4dk(rdnd}|j6|z}t-d |d|||_td|_t1|j<|z|j2|z|j>|j:|j8g|_ |j@jC|jEd|jF|j@_#||_$||_%ycc}}w)z Initialize the legend_box. The legend_box is an instance of the OffsetBox, which is packed with legend handles and texts. Once packed, their location is calculated during the drawing time. gffffff?gffffff?N$Legend does not support handles for z instances. A proxy artist may be used instead. See: https://matplotlib.org/stable/users/explain/axes/legend_guide.html#controlling-the-legend-entriesTbaseliner)verticalalignmenthorizontalalignmentfontproperties)multilinebaseline textpropsg)rCrDrrr)r+sepchildrenalignr)r+rIrKrJrfixed)r+rIrKrxrJrVFr)&rrsr9rr@r warn_externalrrQappendr#rrmr"rr_text legend_artistfilterrr array_splitrr rtr!rqrrv_legend_handle_boxrrprr6rrrMrr)r7rrrirn text_list handle_listhandles_and_labelsdescentrDr=r>labelhandlertextbox handlebox columnboxhandles_and_labels_columnht itemboxesrrxrIs r9rzLegend._init_legend_boxFs>>  /T%6%6%<=D---7"88:"%gv"6 @ K--.@+NG""C $[ 1 : :;?7 @: *0R^^$6 D*F : %&? @"Q !Q%)%7%7(%B4?1a&aV'13@I@ '2 wI   W)-):):X)E+4.79 : : ::1xw  8+")a.1/33<#>"*""t~~'@'+'8'88'C)--1-C-C-1-D-D-FG ##DOOO$?@ $  )7@s9.Kc |jsJg}g}g}|jjD] t tr=|j j j jQt tr=|j jj jt tr=|j j j jt tr*|j fd j!D%t t"rD j%\}}}}t'|sW|j|j)|yt t*s|j j-||||fS)aC Return display coordinates for hit testing for "best" positioning. Returns ------- bboxes List of bounding boxes of all patches. lines List of `.Path` corresponding to each line. offsets List of (x, y) offsets of all collection. c3\K|]#}jj|%ywrL)rtransform_path)rpathartists r9rz+Legend._auto_legend_data..s-=!%$113BB4H=s),)rrW _childrenrr rNrrcget_pathrget_bbox transformedget_data_transformr rextend get_pathsr_prepare_pointsrrGrr%) r7rbboxeslinesoffsetsrG transOffsethoffsets_res @r9_auto_legend_datazLegend._auto_legend_datasu{{{kk++ BF&&) ((*99&//:KLNFI. OO%11&2K2K2MNPFE* ((*99&//:KLNFN3 =)/)9)9);==FJ/6<6L6L6N3 ;!x=NN;#8#8#BCFD) f66x@A% B(ug%%r:c:|j|jgSrL)r6 get_framer?s r9 get_childrenzLegend.get_childrens  $.."233r:c|jS)z:Return the `~.patches.Rectangle` used to frame the legend.)rr?s r9rvzLegend.get_framesr:cb|jDcgc]}t|ts|c}Scc}w)z4Return the list of `~.lines.Line2D`\s in the legend.)rrr r7r^s r9 get_lineszLegend.get_liness%..Ha*Q2GHHHs,,c ttd|jDcgc]}t|tr|c}Scc}w)z5Return the list of `~.patches.Patch`\s in the legend.r )r rrr rzs r9 get_patcheszLegend.get_patchess;7'+':':5!)!U356 65s5 c.td|jS)z1Return the list of `~.text.Text`\s in the legend.r)r rr?s r9 get_textszLegend.get_textss64::..r:cftjgd|||_||j_y)a Set the alignment of the legend title and the box of entries. The entries are aligned as a single block, so that markers always lined up. Parameters ---------- alignment : {'center', 'left', 'right'}. rrN)rr2rr6rK)r7rs r9 set_alignmentzLegend.set_alignments* 6)L#!*r:c.|jjS)z)Get the alignment value of the legend box)r6rKr?s r9 get_alignmentzLegend.get_alignments%%%r:c|jjj||rA|jjjd|jjdn@|jjjd|jjd|%|jjj |d|_y)a Set legend title and title style. Parameters ---------- title : str The legend title. prop : `.font_manager.FontProperties` or `str` or `pathlib.Path` The font properties of the legend title. If a `str`, it is interpreted as a fontconfig pattern parsed by `.FontProperties`. If a `pathlib.Path`, it is interpreted as the absolute path to a font file. TFN)rrOset_text set_visibleset_fontpropertiesr)r7r{rms r9rzLegend.set_titles $$--e4   " " ( ( 4 4T :  " " . .t 4  " " ( ( 4 4U ;  " " . .u 5    " " ( ( ; ;D A r:c.|jjS)z1Return the `.Text` instance for the legend title.)rrOr?s r9 get_titlezLegend.get_titles%%+++r:c~| |jdj}|jj|S)NTr)r)r _get_rendererr6r%r7rs r9r%zLegend.get_window_extents;  D1??AH1181DDr:c8|jj|SrL)r6r%rs r9 get_tightbboxzLegend.get_tightbbox"s11(;;r:c6|jjS)z*Get whether the legend box patch is drawn.)rr r?s r9 get_frame_onzLegend.get_frame_on&s++--r:cH|jj|d|_y)zt Set whether the legend box patch is drawn. Parameters ---------- b : bool TN)rrr)r7bs r9 set_frame_onzLegend.set_frame_on*s $$Q' r:c^|j|jjS|jS)z4Return the bbox that the legend will be anchored to.)_bbox_to_anchorrWr-r?s r9rBzLegend.get_bbox_to_anchor7s*    ';;## #'' 'r:cv|d|_yt|tr||_n4 t|}|dk(r |d|dddg}t j||_|t|jj}t|j||_d|_ y#t$r}t d||d}~wwxYw)a% Set the bbox that the legend will be anchored to. Parameters ---------- bbox : `~matplotlib.transforms.BboxBase` or tuple The bounding box can be specified in the following ways: - A `.BboxBase` instance - A tuple of ``(left, bottom, width, height)`` in the given transform (normalized axes coordinate if None) - A tuple of ``(left, bottom)`` where the width and height will be assumed to be zero. - *None*, to remove the bbox anchoring, and use the parent bbox. transform : `~matplotlib.transforms.Transform`, optional A transform to apply to the bounding box. If not specified, this will use a transform to the bounding box of the parent. NzInvalid bbox: rrr'T) rrrrrrrrrrWr-rr)r7r-rGlerrs r9rEzLegend.set_bbox_to_anchor>s( <#'D  h '#'D  CIAvQa!Q/#'#3#3T#:D  ' (8(89I.t/C/C/8 :  C >$!89sB Cs B B8$B33B8c ~tj||||j|j|jzS)a4 Place the *bbox* inside the *parentbbox* according to a given location code. Return the (x, y) coordinate of the bbox. Parameters ---------- loc : int A location code in range(1, 11). This corresponds to the possible values for ``self._loc``, excluding "best". bbox : `~matplotlib.transforms.Bbox` bbox to be placed, in display coordinates. parentbbox : `~matplotlib.transforms.Bbox` A parent box which will contain the bbox, in display coordinates. )rrrur#r)r7r,r- parentbboxrs r9rzLegend._get_anchored_bboxis=++ z   !:!:4>>!J JL Lr:c|jsJtj}|j|\}}}t j dd||}g} t dt|jD]} |j| ||j|\} } t j | | ||tfd|Dj|zj|ztfd|Dz} | j| | | | ff| dk(snt| \}}\} } |j r/tj|z dkDrt#j$d| | fS)z0Determine the best location to place the legend.rr'c3TK|]}j|j!ywrL)count_containsverticesrline legendBoxs r9rz-Legend._find_best_position..s(.#%33DMMB.s%(c3DK|]}|jdyw)F)filledN)intersects_bboxrs r9rz-Legend._find_best_position..s)0!%"11)E1J0s zGCreating legend with loc="best" can be slow with large amounts of data.)rtime perf_counterrtrrrangerrrrBsumrcount_overlapsrNminrrrM)r7rCrDr start_timernrorpr- candidatesidxrrbadnessrsrs @r9rzLegend._find_best_position|s{{{&&( !%!7!7!Aw1eV4 C O, C**3+/+B+B+D+35DAq((Auf=I.',.."11':;#11&9:0).00 0G   waV4 5!|! $: 1fq!  ! !d&7&7&9J&F&J   # $!t r:c8|jj|SrL)rcontains)r7 mouseevents r9rzLegend.containss((44r:c|r+|jt||||_|jS|j|jjd|_|jS)a Enable or disable mouse dragging support of the legend. Parameters ---------- state : bool Whether mouse dragging is enabled. use_blit : bool, optional Use blitting for faster image composition. For details see :ref:`func-animation`. update : {'loc', 'bbox'}, optional The legend parameter to be changed when dragged: - 'loc': update the *loc* parameter of the legend - 'bbox': update the *bbox_to_anchor* parameter of the legend Returns ------- `.DraggableLegend` or *None* If *state* is ``True`` this returns the `.DraggableLegend` helper instance. Otherwise this returns *None*. Nr.)rr* disconnect)r7rr0r/s r9rzLegend.set_draggables_. &"1$2:9?#A***,"DOr:c|jduS)z@Return ``True`` if the legend is draggable, ``False`` otherwise.N)rr?s r9 get_draggablezLegend.get_draggablesd**r:rL)TrP)NrQrRrS__doc__rrzorderrerinterpdr5rrrr rpropertyrHr r r)r&r( HandlerStemr$HandlerErrorbarr HandlerLine2Dr HandlerPatchrHandlerStepPatchrHandlerLineCollectionrHandlerRegularPolyCollectionrHandlerCircleCollectionr%update_from_first_childrF HandlerTuplerHandlerPathCollectionrHandlerPolyCollectionr/ classmethodr1r4r6r9 staticmethodr@rrtrwrvr{r}rrrrrr%rrr draw_framerBrErrrrrrTrUs@r9raraVs Q 2+11 2E F   ! SJDJDX.@%@%D6 Hh 'D*"J 1~1139>99;,,,. *~**,2>224<<<>J~JJL@.@@B1n11&>>@ *~**,<<<><<<> &((//55F 2b*H%&N4 I6 /+ &:,E <. J()VL&$L5 D+r:rac#,Kg}|D]h}|gd|jD|jz }t|ds4|jD]&}|gd|jD|jz }(jitj |xsi}tj }|D]p}|j}|dk7r|||r|&|s)|jdr;|||rEtjdt|jdryw) z6Yield artists that can be used as handles in a legend.c3`K|]&}t|ttttfr|(ywrLrr r rrrrs r9rz&_get_legend_handles..s,CAAz4@AC,. parasitesc3`K|]&}t|ttttfr|(ywrLrrs r9rz&_get_legend_handles..s,KA#Az4'HIKr _nolegend_rsrBz| instances. See: https://matplotlib.org/stable/tutorials/intermediate/legend_guide.html#implementing-a-custom-legend-handlerN) rf containershasattrrrar1r@ get_label startswithrrMrrQ) axsr=handles_originalaxaxxr has_handlerrrXs r9_get_legend_handlesrsS %CC]]  2{ #|| % %%KK%%^^%%%  % %1V3351(.B1K++K"   " L [f%ELE,,S1 V4   C $V 5 567EE F  s8DB D D D%/Dcg}g}t||D]I}|j}|s|jdr(|j||j|K||fS)z%Return handles and labels for legend.rs)rrrrN)rr=rrrrXs r9_get_legend_handles_labelsrseG F%c+=>!  " ))#. NN6 " MM% ! F?r:)rrctjt}|jd}|||rt j ddt |drPt |drDt|t|k7r-t jdt|dt||r|rtt||\}}n| ||Dcgc]}|j}}n|+|)tt|||Dcgc]\}}| }}}nt|d k(r't||\}}|st jd nt|d k(rJ|\}td |Dr td tt|||Dcgc]\}}| }}}n7t|dk(r |dd\}}n t jddt||||fScc}wcc}}wcc}}w)a Get the handles and labels from the calls to either ``figure.legend`` or ``axes.legend``. The parser is a bit involved because we support:: legend() legend(labels) legend(handles, labels) legend(labels=labels) legend(handles=handles) legend(handles=handles, labels=labels) The behavior for a mixture of positional and keyword handles and labels is undefined and issues a warning; it will be an error in the future. Parameters ---------- axs : list of `.Axes` If handles are not given explicitly, the artists in these Axes are used as handles. *args : tuple Positional parameters passed to ``legend()``. handles The value of the keyword argument ``legend(handles=...)``, or *None* if that keyword argument was not used. labels The value of the keyword argument ``legend(labels=...)``, or *None* if that keyword argument was not used. **kwargs All other keyword arguments passed to ``legend()``. Returns ------- handles : list of (`.Artist` or tuple of `.Artist`) The legend handles. labels : list of str The legend labels. kwargs : dict *kwargs* with keywords handles and labels removed. rNz3.9zYou have mixed positional and keyword arguments, some input may be discarded. This is deprecated since %(since)s and will become an error in %(removal)s.)message__len__z8Mismatched number of handles and labels: len(handles) = z len(labels) = rzNo artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.r'c3<K|]}t|tywrL)rr)rrs r9rz%_parse_legend_args..Ms5z!V$5sz\A single argument passed to legend() must be a list of labels, but found an Artist in there.rr1z0-2)logging getLoggerrQgetrwarn_deprecatedrrrMrrrranyr nargs_error) rrrargskwargsloghandlersrrXs r9_parse_legend_argsrsV   H %Czz-(Hv1t U . 0 # FI & LCK ' --0\N;,,/K=: ;6s7F34  3:;&""$;;  -c8 G G"rL)Irrrrrnumpyr matplotlibrrrrrrmatplotlib.artistrr matplotlib.cbookr matplotlib.font_managerr matplotlib.linesr matplotlib.patchesr rrrrmatplotlib.collectionsrrrrrrmatplotlib.textrmatplotlib.transformsrrrrrmatplotlib.offsetboxrrr r!r"r#matplotlib.containerr$r%r&rVr(r*_legend_kw_doc_base _loc_doc_base _loc_doc_bestformat_legend_kw_axes_strregister _outside_doc_legend_kw_figure_st_legend_kw_both_st_legend_kw_set_loc_strarrrrdr:r9rs. AA9(2#++++!AAD PO)4()4X^@% N 0B+R9 ,>?  / ,8 .BC !V+\C  +=> !V+\C 3HIs +Vs +pD ,0_#r: