rL i7x fdZddlZddlZddlZddlmZmZddlZddlZ ddl Z ddl m Z mZmZmZmZmZmZmZmZmZmZddlmZmZe j@ddgd d gd d ggd ddgdgdGddejBZ"Gdde"Z#Gdde#Z$Gdde#Z%Gdde%Z&Gdde#Z'Gdde'Z(Gd d!e'Z)Gd"d#e"Z*Gd$d%e*Z+Gd&d'e#Z,Gd(d)e"Z-Gd*d+e"Z.Gd,d-e"Z/Gd.d/Z0Gd0d1e0e"Z1Gd2d3e0e%Z2y)4ay Classes for the efficient drawing of large collections of objects that share most properties, e.g., a large number of line segments or polygons. The classes are not meant to be as flexible as their single element counterparts (e.g., you may not be able to select all line styles) but they are meant to be fast for common use cases (e.g., a large set of solid line segments). N)NumberReal) _api_pathartistcbook colorizercolors _docstringhatchlinespath transforms) JoinStyleCapStyle antialiasedsaa edgecolorsec facecolorsfc) linestylesdashesls linewidthslw transOffset) antialiased edgecolor facecolor linestyle linewidthoffset_transformceZdZdZej dZdZejdddddddddddddddddfd Z d Z d Z d Z d ZdZdZd9dZdZej(dZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#ejd!Z$ejd"Z%ejd#Z&ejd$Z'e(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0d-Z1d.Z2d/Z3d0Z4d1Z5d2Z6ejnjpje6_d3Z9d4Z:d5Z;d6ZxZ?S): Collectiona Base class for Collections. Must be subclassed to be usable. A Collection represents a sequence of `.Patch`\es that can be drawn more efficiently together than individually. For example, when a single path is being drawn repeatedly at different offsets, the renderer can typically execute a ``draw_marker()`` call much more efficiently than a series of repeated calls to ``draw_path()`` with the offsets put in one-by-one. Most properties of a collection can be configured per-element. Therefore, Collections have "plural" versions of many of the properties of a `.Patch` (e.g. `.Collection.get_paths` instead of `.Patch.get_path`). Exceptions are the *zorder*, *hatch*, *pickradius*, *capstyle* and *joinstyle* properties, which can only be set globally for the whole collection. Besides these exceptions, all properties can be specified as single values (applying to all elements) or sequences of values. The property of the ``i``\th element of the collection is:: prop[i % len(prop)] Each Collection can optionally be used as its own `.ScalarMappable` by passing the *norm* and *cmap* parameters to its constructor. If the Collection's `.ScalarMappable` matrix ``_A`` has been set (via a call to `.Collection.set_array`), then at draw time this internal scalar mappable will be used to set the ``facecolors`` and ``edgecolors``, ignoring those that were manually passed in. rr(FNsolidg@r)rrrrcapstyle joinstyleroffsetsr$normcmapr pickradiusr urlszorderc t||j| | | dg|_dg|_dg|_dg|_d|_d|_d|_ d|_ tjtjd|_tjd|_|j#||j%||j'||j)||j+||j-| |j/||j1||j3||r|j5|nd|_|r|j9|nd|_|2t=j>|t@}|jBdk(r |dddf}||_"| |_#d|_$|jK|d|_&y)a Parameters ---------- edgecolors : :mpltype:`color` or list of colors, default: :rc:`patch.edgecolor` Edge color for each patch making up the collection. The special value 'face' can be passed to make the edgecolor match the facecolor. facecolors : :mpltype:`color` or list of colors, default: :rc:`patch.facecolor` Face color for each patch making up the collection. linewidths : float or list of floats, default: :rc:`patch.linewidth` Line width for each patch making up the collection. linestyles : str or tuple or list thereof, default: 'solid' Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:: (offset, onoffseq), where *onoffseq* is an even length tuple of on and off ink lengths in points. For examples, see :doc:`/gallery/lines_bars_and_markers/linestyles`. capstyle : `.CapStyle`-like, default: 'butt' Style to use for capping lines for all paths in the collection. Allowed values are %(CapStyle)s. joinstyle : `.JoinStyle`-like, default: 'round' Style to use for joining lines for all paths in the collection. Allowed values are %(JoinStyle)s. antialiaseds : bool or list of bool, default: :rc:`patch.antialiased` Whether each patch in the collection should be drawn with antialiasing. offsets : (float, float) or list thereof, default: (0, 0) A vector by which to translate each patch after rendering (default is no translation). The translation is performed in screen (pixel) coordinates (i.e. after the Artist's transform is applied). offset_transform : `~.Transform`, default: `.IdentityTransform` A single transform which will be applied to each *offsets* vector before it is used. cmap, norm Data normalization and colormapping parameters. See `.ScalarMappable` for a detailed description. hatch : str, optional Hatching pattern to use in filled paths, if any. Valid strings are ['/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*']. See :doc:`/gallery/shapes_and_collections/hatch_style_reference` for the meaning of each hatch type. pickradius : float, default: 5.0 If ``pickradius <= 0``, then `.Collection.contains` will return ``True`` whenever the test point is inside of one of the polygons formed by the control points of a Path in the Collection. On the other hand, if it is greater than 0, then we instead check if the test point is contained in a stroke of width ``2*pickradius`` following any of the Paths in the Collection. urls : list of str, default: None A URL for each patch to link to once drawn. Currently only works for the SVG backend. See :doc:`/gallery/misc/hyperlinks_sgskip` for examples. zorder : float, default: 1 The drawing order, shared by all Patches in the Collection. See :doc:`/gallery/misc/zorder_demo` for all defaults and examples. **kwargs Remaining keyword arguments will be used to set properties as ``Collection.set_{key}(val)`` for each key-value pair in *kwargs*. rNrNz hatch.colorzhatch.linewidth)'super__init___get_colorizer_us_linestyles _linestyles_us_lw _linewidths _gapcolor_face_is_mapped_edge_is_mapped_mapped_colorsmcolorsto_rgbamplrcParams _hatch_color_hatch_linewidth set_facecolor set_edgecolor set_linewidth set_linestyleset_antialiasedset_pickradiusset_urls set_hatch set_zorder set_capstyle _capstyle set_joinstyle _joinstylenp asanyarrayfloatshape_offsets_offset_transform _path_effects_internal_update_paths)selfrrrrr*r+rr,r$r-r.r r/r r0r1kwargs __class__s \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/collections.pyr7zCollection.__init__Nsf ,,T4CD )k%;c 3 $#"#OOCLL,GH # -> ? :& :& :& :& \* J' d u     h '!DN    y )"DO  mmGU3G}}$!$'* !1! f% c|jSNr\r]s r` get_pathszCollection.get_paths {{rac ||_d|_yNT)r\stale)r]pathss r` set_pathszCollection.set_pathss  rac|jSrc) _transformsres r`get_transformszCollection.get_transformsracD|j%tj|_|jSt|jtjs@t |jdr*|jj |j|_|jS)z ? '255#4#45!..044$$&2E##%//8%%'..0 2 2 == $ "I-88AGee**73G<<##%!++-((1 ##%%ILs3IcH|jtjSrc)rrrs)r]renderers r`get_window_extentzCollection.get_window_extent7s < < >??rac |j}|j}|j}|j}|j rg}|jD]}|j }|dddf|dddf}}|j |}|j|}|jtjtj||g|j|j |dddf}|j|dddf}tjj||g}|js.|Dcgc]}|j!|}}|j#}|js!|j%|}|j#}t'|tjj(r|j+tj,}||||fScc}w)Nrr)r|rxrrf have_unitsverticesconvert_xunitsconvert_yunitsappendrPathrT column_stackcodesrrrrrrtrrr) r]rrr,rkrrxsyss r`_prepare_pointszCollection._prepare_points<s&&( ..0 ""$  ?? E( P==!!Q$!Q$B((,((, UZZR(A4::NO  P $$WQT]3B$$WQT]3Bee(("b2G""!&(88>(E(!,,.I## 55g>G#..0J gruu00 1nnRVV,G*gu44(s G-c |jsy|j|jj|j |j |j \}}}}|j}|j||j|j|jrQ|j|j|j|j|j|j |j#|j$|j#|j'rddlm}||j'|}|j-}|j/} |j1} d} t3|dk(rGt3|dkr8t3| dk(r)t3| dk(rt3|j4dk(rt7d|j8Drt3|j:dk(rt3|j<dk(r|j?t3|rtAjB|d|z} n|} |djE| } | jF|jIdjJjFkr5| jL|jIdjJjLkrd} |jNr|jQ|jN|jRr|jU|jR| r|jWtY| d|j[|j4d|j\|j8d|j_|j:d|ja|j<d|jc||d jetgjh||tY| dn|jj|jm\}}|jo||je||j-||tqjrdg|jj|j4||j:|j<d |jo||je||j-|||j/|j1|j4|j8|j:|j<d |ju|jw|jjd|_<y) Nr)PathEffectRendererFrc3*K|] }|ddu yw)rN).0rs r` z"Collection.draw..s=bBqETM=sTrootnonescreen)= get_visible open_groupr___name__get_gidupdate_scalarmappablernew_gc _set_gc_clipset_snapget_snap_hatchrNset_hatch_colorrEset_hatch_linewidthrFget_sketch_paramsset_sketch_paramsget_path_effectsmatplotlib.patheffectsrro get_facecolor get_edgecolorrr<rr: _antialiaseds_urls get_hatchrAffine2D get_extentswidth get_figurerheightrSrRrQrPset_foregroundtuplerI set_dashesrKset_url draw_markersrrrr=_get_inverse_paths_linestylesdraw_path_collectionrArBrestore close_grouprj)r]rrrr,rkgcrtransrrdo_single_path_optimizationcombined_transformextentsipaths ilinestyless r`drawzCollection.draw`s@! DNN33T\\^D ""$040D0D0F- :w __  " DMMO$ ;; LL %   t00 1  " "4#8#8 9  ! ! # / B $"8"8": ;  " A)$*?*?*A8LH##%'') '') &+# J!OE aJ1$ZA)=D$$%*=D,<,<==D&&'1,TZZA1E (5z%/%8%8q%BY%N"%."Ah**+=>G T : ? ? E EEd)C)H)H)O)OO.2+ ??   T__ - >> OODNN + &   eJqM2 3   T--a0 1 BMM4++A. /   t11!4 5 JJtzz!} %  ! !E!H0779 7#Zz!}1E G~~)&*&H&H&J# -- ((*F'')7J__V,-t~~$$k&&    ) )I$$&##%w ""$d&8&8&:  $"2"2""DJJ   T^^445 racNt|tstd|||_y)z Set the pick radius used for containment tests. Parameters ---------- pickradius : float Pick radius, in points. z-pickradius must be a real-valued number, not N)rtr ValueError _pickradius)r]r/s r`rLzCollection.set_pickradiuss/*d+? ~NP P%rac|jSrc)rres r`get_pickradiuszCollection.get_pickradiusrprac (|j|s|jsdifSt|jtr#|jdurt |jn |j }|jr|jj|j\}}}}tj|j|j||j||j|||dk }t!|dkDt#|fS)z Test whether the mouse event occurred in the collection. Returns ``bool, dict(ind=itemlist)``, where every item in itemlist contains the event. FTr)ind)_different_canvasrrt_pickerrrVrrw_unstale_viewLimrrpoint_in_path_collectionxyrrordict)r] mouseeventr/rrr,rkrs r`containszCollection.containss  ! !* -T5E5E5G"9 $,,/||4' $,, !!  99 II & & (040D0D0F- :w ,, LL*,,    t':':'< Zq23x!|Tc]**rac*||ndg|_d|_y)z Parameters ---------- urls : list of str or None Notes ----- URLs are currently only implemented by the SVG backend. They are ignored by all other backends. NT)rrj)r]r0s r`rMzCollection.set_urlss"-TD6  rac|jS)z Return a list of URLs, one for each element of the collection. The list contains *None* for elements without a URL. See :doc:`/gallery/misc/hyperlinks_sgskip` for an example. )rres r`get_urlszCollection.get_urlsszzracJtj|||_d|_y)a+ Set the hatching pattern *hatch* can be one of:: / - diagonal hatching \ - back diagonal | - vertical - - horizontal + - crossed x - crossed diagonal o - small circle O - large circle . - dots * - stars Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern. Unlike other properties such as linewidth and colors, hatching can only be specified for the collection as a whole, not separately for each member. Parameters ---------- hatch : {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} TN)mhatch_validate_hatch_patternrrj)r]r s r`rNzCollection.set_hatchs < &&u-  rac|jS)z$Return the current hatching pattern.)rres r`rzCollection.get_hatch s {{rac||_y)zSet the hatch linewidth.NrFr]rs r`rzCollection.set_hatch_linewidth$s "rac|jS)zReturn the hatch linewidth.rres r`get_hatch_linewidthzCollection.get_hatch_linewidth(s$$$rac tj|}|jdk(r |dddf}t|tjj rtjj ntj }|tj|j|dddfttj|j|dddftf|_ d|_ y)z Set the offsets for the collection. Parameters ---------- offsets : (N, 2) or (2,) array-like r4NrrT) rTrUrWrtrrrrrVrrXrj)r]r,cstacks r` set_offsetszCollection.set_offsets,s--( ==D dAg&G(27BEEs%$(==#8rxxKdmmKrac(tjdS)Nzpatch.linewidthrCrDres r`_get_default_linewidthz!Collection._get_default_linewidthC||-..rac||j}tj||_|j |j|j \|_|_d|_y)z Set the linewidth(s) for the collection. *lw* can be a scalar or a sequence; if it is a sequence the patches will cycle through the sequence Parameters ---------- lw : float or list of floats NT) rrT atleast_1dr; _bcast_lwlsr9r<r:rjrs r`rIzCollection.set_linewidthGsZ :,,.BmmB' .2-=-= KK,,..*$* ractj||_|j|j|j\|_|_y)a Set the linestyle(s) for the collection. =========================== ================= linestyle description =========================== ================= ``'-'`` or ``'solid'`` solid line ``'--'`` or ``'dashed'`` dashed line ``'-.'`` or ``'dashdot'`` dash-dotted line ``':'`` or ``'dotted'`` dotted line =========================== ================= 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. Parameters ---------- ls : str or tuple or list thereof Valid values for individual linestyles include {'-', '--', '-.', ':', '', (offset, on-off-seq)}. See `.Line2D.set_linestyle` for a complete description. N)mlines_get_dash_patternsr9rr;r<r:)r]rs r`rJzCollection.set_linestyle[sC6%77;.2-=-= KK,,..*$*rac$t||_y)z Set the `.CapStyle` for the collection (for all its elements). Parameters ---------- cs : `.CapStyle` or %(CapStyle)s N)rrQ)r]css r`rPzCollection.set_capstyle|s""racJ|jr|jjSdS)z Return the cap style for the collection (for all its elements). Returns ------- %(CapStyle)s or None N)rQnameres r` get_capstylezCollection.get_capstyles'+nnt~~"">$>rac$t||_y)z Set the `.JoinStyle` for the collection (for all its elements). Parameters ---------- js : `.JoinStyle` or %(JoinStyle)s N)rrS)r]jss r`rRzCollection.set_joinstyles$B-racJ|jr|jjSdS)z Return the join style for the collection (for all its elements). Returns ------- %(JoinStyle)s or None N)rSr res r` get_joinstylezCollection.get_joinstyles(,t##@D@rac tjdr||fSt|t|k7rNt|}t|}tj||}t |||zz}t |||zz}t ||Dcgc]\\}}}tj|||!}}}}||fScc}}}w)a Internal helper function to broadcast + scale ls/lw In the collection drawing code, the linewidth and linestyle are cycled through as circular buffers (via ``v[i % len(v)]``). Thus, if we are going to scale the dash pattern at set time (not draw time) we need to do the broadcasting now and expand both lists to be the same length. Parameters ---------- linewidths : list line widths of collection dashes : list dash specification (offset, (dash pattern tuple)) Returns ------- linewidths, dashes : list Will be the same length, dashes are scaled by paired linewidth z_internal.classic_mode) rCrDrmathgcdlistzipr _scale_dashes)rrl_dashesl_lwrodrs r`rzCollection._bcast_lwlss, <<0 1v% % v;#j/ )6{Hz?D((8T*C&\TS[1Fj)X_=J%( $;== fq!b&&q!R0==6!!=s $B9c|jS)zs Get the antialiasing state for rendering. Returns ------- array of bools )rres r`get_antialiasedzCollection.get_antialiaseds!!!rac||j}tjtj|t|_d|_y)z Set the antialiasing state for rendering. Parameters ---------- aa : bool or list of bools NT)_get_default_antialiasedrTrasarrayboolrrj)r]rs r`rKzCollection.set_antialiaseds: :..0B]]2::b$+?@ rac(tjdS)Nzpatch.antialiasedrres r`rz#Collection._get_default_antialiaseds||/00racH|j||j|y)a1 Set both the edgecolor and the facecolor. Parameters ---------- c : :mpltype:`color` or list of RGBA tuples See Also -------- Collection.set_facecolor, Collection.set_edgecolor For setting the edge or face color individually. N)rGrHr]cs r` set_colorzCollection.set_colors  1 1rac(tjdS)Nzpatch.facecolorrres r`_get_default_facecolorz!Collection._get_default_facecolorrrac||j}tj||j|_d|_yri)r(rA to_rgba_array_alpha _facecolorsrjr$s r`_set_facecolorzCollection._set_facecolors5 9++-A"00DKK@ ract|tr"|jdvr|j}||_|j |y)an Set the facecolor(s) of the collection. *c* can be a color (all patches have same color), or a sequence of colors; if it is a sequence the patches will cycle through the sequence. If *c* is 'none', the patch will not be filled. Parameters ---------- c : :mpltype:`color` or list of :mpltype:`color` rfaceN)rtstrlower_original_facecolorr-r$s r`rGzCollection.set_facecolors= a !'')/?"? A#$  Arac|jSrc)r,res r`rzCollection.get_facecolorrpracztj|jdr|jS|jS)Nr0)r _str_equal _edgecolorsrres r`rzCollection.get_edgecolors3   D,,f 5%%' '## #rac(tjdS)Nzpatch.edgecolorrres r`_get_default_edgecolorz!Collection._get_default_edgecolorrracd}|Ttjds,|js tj|j dr|j }nd}d}tj|drd|_d|_ ytj||j|_|r2t|jrt|jd|_d|_ y)NTzpatch.force_edgecolorrFr0r)rCrD _edge_defaultr r6r3r9_str_lower_equalr7rjrAr*r+rrrE)r]r%rs r`_set_edgecolorzCollection._set_edgecolor"s 9 45))''(@(@&I//1"'  ! !!V ,%D DJ "00DKK@ s4#3#34 %d&6&6q&9 :D  ract|tr"|jdvr|j}||_|j |y)a' Set the edgecolor(s) of the collection. Parameters ---------- c : :mpltype:`color` or list of :mpltype:`color` or 'face' The collection edgecolor(s). If a sequence, the patches cycle through it. If 'face', match the facecolor. r/N)rtr1r2_original_edgecolorr=r$s r`rHzCollection.set_edgecolor5s= a !'')/?"? A#$  Aractjj|||j|j|j |j y)a Set the transparency of the collection. Parameters ---------- alpha : float or array of float or None If not None, *alpha* values must be between 0 and 1, inclusive. If an array is provided, its length must match the number of elements in the collection. Masked values and nans are not supported. N)rArtist_set_alpha_for_arrayr-r3r=r?)r]alphas r` set_alphazCollection.set_alphaGs@  **47 D445 D445rac|jSrc)r<res r` get_linewidthzCollection.get_linewidthYrprac|jSrc)r:res r` get_linestylezCollection.get_linestyle\rprac|j}|j}d|_d|_|jbtj|j ds/d|_tj|j drd|_n|j d|_|jxs |j}|duxs&|duxs |j|k7xs|j|k7}|xs|S)aF Determine whether edges and/or faces are color-mapped. This is a helper for update_scalarmappable. It sets Boolean flags '_edge_is_mapped' and '_face_is_mapped'. Returns ------- mapping_change : bool True if either flag is True, or if a flag has changed. FNrTr0)r?r>_Ar r6r3r?)r]edge0face0mappedchangeds r`_set_mappable_flagszCollection._set_mappable_flags_s$$$$$$ 77 ##D$<$r,r-r3r?r7r=r?rjres r`rz Collection.update_scalarmappablesK'')  77 ww||a 4(C !IJJ{{4;;';;##tww||3$,TWW]]Or3r,r<r:r9rrrJr-r.rj)r]others r`rYzCollection.update_froms  !!$."00#22$44#(#<#<  ,,$44#(#<#<  ,, ,, ,,#22 ,,ll ((JJ JJ  rarc)@r __module__ __qualname____doc__rTemptyrnr;r interpdr7rfrlrorxrzrrrrallow_rasterizationrrLrrrMrrNrrrrrrrIrJrPr rRr staticmethodrrrKrr&r(r-rGrrr9r=rHrDrArBrFrHrOrrWrY __classcell__r_s@r`r&r&sF"((9%KM   #""&!CCJ &2C&J@ "5H W Wr & +8  D#%$L /(.B&&??((AA#"#"J" 1 /" $ /&$6  ::BBI   !D$LLrar&cReZdZdZdZdZddZejfdZ xZ S)_CollectionWithSizeszA Base class for collections that have an array of sizes. ?c|jS)z Return the sizes ('areas') of the elements in the collection. Returns ------- array The 'area' of each element. )_sizesres r` get_sizesz_CollectionWithSizes.get_sizess{{rac|$B$BC  Xra)rk) rr[r\r]rnrirrrr`rrbrcs@r`reres3G 0  rarec<eZdZdZd fd ZdZddddfdZxZS) PathCollectionzO A collection of `~.path.Path`\s, as created by e.g. `~.Axes.scatter`. Nc vt|di||j||j|d|_y)a Parameters ---------- paths : list of `.path.Path` The paths that will make up the `.Collection`. sizes : array-like The factor by which to scale each drawn `~.path.Path`. One unit squared in the Path's data space is scaled to be ``sizes**2`` points when rendered. **kwargs Forwarded to `.Collection`. TNr)r6r7rlrrrj)r]rkror^r_s r`r7zPathCollection.__init__s4 "6" u u rac|jSrcrdres r`rfzPathCollection.get_paths rgrar autoc|Srcr)rs r`zPathCollection.srac g}g}|jdu}|"tjjdd}n/t |t rtjj |}|j|dk(rb|stjd||fStj|j} |jdtjd} nJ|d k(r6tj|j} |jd d } ntd |d || } |j j#| j%| j'|j j)| j%| j'|dk(rd}t+| |krd}| | } || }n|dk(r|j}n|d k(r|j}t |tjj,r|}ngtj.|r tjj1|}n2t3|}tjj5||dz gd}|j7|j%||j'}|||j%k\|||j'kz}||}tj8|j%|j'd}||}tj:|}tj<|||||} |j?d|jAd|}tC| |D]\}}|dk(r!|jE|jG|} n1|d k(r,tjH|} tjJ| dr]tMjNdgdgfd  |jQdd|}|jS|tU|dr|jW|||}|jS|||fS)a Create legend handles and labels for a PathCollection. Each legend handle is a `.Line2D` representing the Path that was drawn, and each label is a string that represents the Path. This is useful for obtaining a legend for a `~.Axes.scatter` plot; e.g.:: scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3], num=None) plt.legend(*scatter.legend_elements()) creates three legend elements, one for each color with the numerical values passed to *c* as the labels. Also see the :ref:`automatedlegendcreation` example. Parameters ---------- prop : {"colors", "sizes"}, default: "colors" If "colors", the legend handles will show the different colors of the collection. If "sizes", the legend will show the different sizes. To set both, use *kwargs* to directly edit the `.Line2D` properties. num : int, None, "auto" (default), array-like, or `~.ticker.Locator` Target number of elements to create. If None, use all unique elements of the mappable array. If an integer, target to use *num* elements in the normed range. If *"auto"*, try to determine which option better suits the nature of the data. The number of created elements may slightly deviate from *num* due to a `~.ticker.Locator` being used to find useful locations. If a list or array, use exactly those elements for the legend. Finally, a `~.ticker.Locator` can be provided. fmt : str, `~matplotlib.ticker.Formatter`, or None (default) The format or formatter to use for the labels. If a string must be a valid input for a `.StrMethodFormatter`. If None (the default), use a `.ScalarFormatter`. func : function, default: ``lambda x: x`` Function to calculate the labels. Often the size (or color) argument to `~.Axes.scatter` will have been pre-processed by the user using a function ``s = f(x)`` to make the markers visible; e.g. ``size = np.log10(x)``. Providing the inverse of this function here allows that pre-processing to be inverted, so that the legend labels have the correct values; e.g. ``func = lambda x: 10**x``. **kwargs Allowed keyword arguments are *color* and *size*. E.g. it may be useful to set the color of the markers if *prop="sizes"* is used; similarly to set the size of the markers if *prop="colors"* is used. Any further parameters are passed onto the `.Line2D` instance. This may be useful to e.g. specify a different *markeredgecolor* or *alpha* for the legend handles. Returns ------- handles : list of `.Line2D` Visual representation of each element of the legend. labels : list of str The string labels for elements of the legend. NFT) useOffset useMathTextr zfCollection without array used. Make sure to specify the values to be colormapped via the `c` argument.rTzlines.markersizerocolorkz?Valid values for `prop` are 'colors' or 'sizes'. You supplied 'z ' instead.rz r)rr5g@r( )nbins min_n_ticksstepsr)markeredgewidthrCg)rrmsmarkerset_locs), get_arrayrCtickerScalarFormatterrtr1StrMethodFormattercreate_dummy_axiswarningswarnrTuniquepoprDriraxisset_view_intervalminmaxset_data_intervalrLocatorrS FixedLocatorint MaxNLocator tick_valueslinspaceargsortinterpget_linewidths get_alpharr.r-rmiscloserLine2Drfrrvr)r]propnumfmtfuncr^handleslabelshasarrayurTrfuvalues label_valuesarrloccondyarrxarrixkwvallabhls r`legend_elementszPathCollection.legend_elementss~>>#4/ ;**,,u$,OC S !**//4C  8  ./& $..*+A::fcll3E&FGD W_ $..*+AJJw,E77;fJHI I!W ""2668RVVX6 ""2668RVVX6 &=C1v} ;F@A NN1 sJ' \*CA MM!  rarc)rr[r\r]r7rfrrbrcs@r`rwrws$&$, {Jrarwc8eZdZdddfd ZddZeZdZxZS)PolyCollectionT)closedc xt|di||j||j||d|_y)aA Parameters ---------- verts : list of array-like The sequence of polygons [*verts0*, *verts1*, ...] where each element *verts_i* defines the vertices of polygon *i* as a 2D array-like of shape (M, 2). sizes : array-like, default: None Squared scaling factors for the polygons. The coordinates of each polygon *verts_i* are multiplied by the square-root of the corresponding entry in *sizes* (i.e., *sizes* specify the scaling of areas). The scaling is applied before the Artist master transform. closed : bool, default: True Whether the polygon should be closed by adding a CLOSEPOLY connection at the end. **kwargs Forwarded to `.Collection`. TNr)r6r7rr set_vertsrj)r]vertsrorr^r_s r`r7zPolyCollection.__init__s6( "6" u uf% racJd|_t|tjjr2|j t jtj}|s)|Dcgc]}tj|c}|_ yt|tjrt|jdk(rtj||ddddffd}tj |jdtjj"}tjj$|ddtjj&|d<tjj(|d<|Dcgc]}tj||c}|_ yg|_ |D]t}t|r9|jj+tjj-|G|jj+tj|vycc}wcc}w) a Set the vertices of the polygons. Parameters ---------- verts : list of array-like The sequence of polygons [*verts0*, *verts1*, ...] where each element *verts_i* defines the vertices of polygon *i* as a 2D array-like of shape (M, 2). closed : bool, default: True Whether the polygon should be closed by adding a CLOSEPOLY connection at the end. TNr(rrdtyper)rjrtrTrrastyperVrrrrr\ndarrayrrW concatenater^ code_typeLINETOMOVETO CLOSEPOLYr_create_closed)r]rrxy verts_padrs r`rzPolyCollection.set_vertss eRUU.. /LL'..rvv6E49:b5::b>:DK  eRZZ (S-=-BuQU|'<1EIHHY__Q/uzz7K7KLEzz((E!Hzz((E!H ,,E"I;DER5::b%0EDK   3B2w ""5::#<#2  3!;Fs $H4H ct|t|k7r tdt||Dcgc];\}}t|rtj||ntj|=c}}|_d|_ycc}}w)z$Initialize vertices with path codes.zB'codes' must be a 1D list or array with the same length of 'verts'TN)rrrrrr\rj)r]rrrcdss r`set_verts_and_codesz"PolyCollection.set_verts_and_codessw u:U #?@ @'*%&79"2s/2"guzz"c*5::b>I9  9sABrc)T)rr[r\r7rrlrrbrcs@r`rrs!D2(3TIrarceZdZdZddddfd ZedZedZddd Z d Z d Z d Z ed Z dZedZedZdZxZS)FillBetweenPolyCollectionzK `.PolyCollection` that fills the area between two x- or y-curves. NF)where interpolatestepc x||_||_||_|j||||} t || fi|y)aY Parameters ---------- t_direction : {{'x', 'y'}} The axes on which the variable lies. - 'x': the curves are ``(t, f1)`` and ``(t, f2)``. - 'y': the curves are ``(f1, t)`` and ``(f2, t)``. t : array-like The ``t_direction`` coordinates of the nodes defining the curves. f1 : array-like or float The other coordinates of the nodes defining the first curve. f2 : array-like or float The other coordinates of the nodes defining the second curve. where : array-like of bool, optional Define *where* to exclude some {dir} regions from being filled. The filled regions are defined by the coordinates ``t[where]``. More precisely, fill between ``t[i]`` and ``t[i+1]`` if ``where[i] and where[i+1]``. Note that this definition implies that an isolated *True* value between two *False* values in *where* will not result in filling. Both sides of the *True* position remain unfilled due to the adjacent *False* values. interpolate : bool, default: False This option is only relevant if *where* is used and the two curves are crossing each other. Semantically, *where* is often used for *f1* > *f2* or similar. By default, the nodes of the polygon defining the filled region will only be placed at the positions in the *t* array. Such a polygon cannot describe the above semantics close to the intersection. The t-sections containing the intersection are simply clipped. Setting *interpolate* to *True* will calculate the actual intersection point and extend the filled region up to this point. step : {{'pre', 'post', 'mid'}}, optional Define *step* if the filling should be a step function, i.e. constant in between *t*. The value determines where the step will occur: - 'pre': The f value is continued constantly to the left from every *t* position, i.e. the interval ``(t[i-1], t[i]]`` has the value ``f[i]``. - 'post': The y value is continued constantly to the right from every *x* position, i.e. the interval ``[t[i], t[i+1])`` has the value ``f[i]``. - 'mid': Steps occur half-way between the *t* positions. **kwargs Forwarded to `.PolyCollection`. See Also -------- .Axes.fill_between, .Axes.fill_betweenx N) t_direction _interpolate_step _make_vertsr6r7) r]rtf1f2rrrr^rr_s r`r7z"FillBetweenPolyCollection.__init__sE@''   BE2 )&)rac:|dk(ry|dk(ryd|}t|)z/The direction that is other than `t_direction`.rrz$t_direction must be 'x' or 'y', got )r)rmsgs r` _f_dir_from_tz'FillBetweenPolyCollection._f_dir_from_t6s0 #  C 8HCS/ !rac8|j|jS)z4The direction that is other than `self.t_direction`.)rrres r` _f_directionz&FillBetweenPolyCollection._f_directionAs!!$"2"233ra)rc|jj|j|j|||\}}}|j ||||}|j |y)a- Set new values for the two bounding curves. Parameters ---------- t : array-like The ``self.t_direction`` coordinates of the nodes defining the curves. f1 : array-like or float The other coordinates of the nodes defining the first curve. f2 : array-like or float The other coordinates of the nodes defining the second curve. where : array-like of bool, optional Define *where* to exclude some {dir} regions from being filled. The filled regions are defined by the coordinates ``t[where]``. More precisely, fill between ``t[i]`` and ``t[i+1]`` if ``where[i] and where[i+1]``. Note that this definition implies that an isolated *True* value between two *False* values in *where* will not result in filling. Both sides of the *True* position remain unfilled due to the adjacent *False* values. See Also -------- .PolyCollection.set_verts, .Line2D.set_data N)rw_fill_between_process_unitsrrrr)r]rrrrrs r`set_dataz"FillBetweenPolyCollection.set_dataFsY8II99   d//B< 2r  BE2 urac tjj}|j|j |z j t j|j|jjgg|S)z7Calculate the data limits and return them as a `.Bbox`.) rr~rrr|rrTr_bboxminpos)r]rdatalims r`rz%FillBetweenPolyCollection.get_datalimhse//&&(##T%7%7%9I%E$P$P NNDJJ):):(;< =%? @rac|j|j|j||||j||||}t j t j |||d\}}}tjj|_ |jj|jt j||fDcgc]!}t j||||fd#c}tj |Dcgc]\}}|j#|||||c}}Scc}wcc}}w)zH Make verts that can be forwarded to `.PolyCollection`. T)subokrr)_validate_shapesrr_get_data_maskrTbroadcast_arraysrrr~rrr_fix_pts_xy_orderrstackr contiguous_regions_make_verts_for_region)r]rrrrfidx0idx1s r`rz%FillBetweenPolyCollection._make_vertsos  d..0A0A1b"M##Ar2u5'' a(8"bM 2r__))+  &&t'='=bnn>@"XNG89BHHah%) 3NG?H(I J $66u= d  ' '2r4 >  NG s &D6D;c |d}nptj|t}|j|jk7r.sN41aQNs)r12rz is not 1-dimensionalz4{!r} has size {}, but {!r} has an unequal size of {}N)rrQrrTr) t_dirf_dirrrrnamesr rlrs r`rz*FillBetweenPolyCollection._validate_shapessO3ue'$B$BC%%     " ) )4>>/ : E E G  h'  sAB()rr[r\r]rrunit_regular_polygonr/rTpirnr7r4r7rr`rrbrcs@r`r*r*sT3jj55OeeoG  (;T ( (rar*c<eZdZdZej j Zy)StarPolygonCollectionz:Draw a collection of regular stars with *numsides* points.N)rr[r\r]rrunit_regular_starr/rrar`r>r> sDjj22Orar>c<eZdZdZej j Zy)AsteriskPolygonCollectionz>Draw a collection of regular asterisks with *numsides* points.N)rr[r\r]rrunit_regular_asteriskr/rrar`rArA%sHjj66OrarAceZdZdZdZddfd ZdZeZeZdZ dZ d Z d Z d Z fd Zd ZeZdZeZdZdZdZdZxZS)LineCollectiona Represents a sequence of `.Line2D`\s that should be drawn together. This class extends `.Collection` to represent a sequence of `.Line2D`\s instead of just a sequence of `.Patch`\s. Just as in `.Collection`, each property of a *LineCollection* may be either a single value or a list of values. This list is then used cyclically for each element of the LineCollection, so the property of the ``i``\th element of the collection is:: prop[i % len(prop)] The properties of each member of a *LineCollection* default to their values in :rc:`lines.*` instead of :rc:`patch.*`, and the property *colors* is added in place of *edgecolors*. Tr5)r1c n|jddt|dd|i||j|y)a Parameters ---------- segments : list of (N, 2) array-like A sequence ``[line0, line1, ...]`` where each line is a (N, 2)-shape array-like containing points:: line0 = [(x0, y0), (x1, y1), ...] Each line can contain a different number of points. linewidths : float or list of float, default: :rc:`lines.linewidth` The width of each line in points. colors : :mpltype:`color` or list of color, default: :rc:`lines.color` A sequence of RGBA tuples (e.g., arbitrary color strings, etc, not allowed). antialiaseds : bool or list of bool, default: :rc:`lines.antialiased` Whether to use antialiasing for each line. zorder : float, default: 2 zorder of the lines once drawn. facecolors : :mpltype:`color` or list of :mpltype:`color`, default: 'none' When setting *facecolors*, each line is interpreted as a boundary for an area, implicitly closing the path from the last point to the first point. The enclosed area is filled with *facecolor*. In order to manually specify what should count as the "interior" of each line, please use `.PathCollection` instead, where the "interior" can be specified by appropriate usage of `~.path.Path.CLOSEPOLY`. **kwargs Forwarded to `.Collection`. rrr1Nr) setdefaultr6r7 set_segments)r]segmentsr1r^r_s r`r7zLineCollection.__init__>sCL ,/     (#rac |y|Dcgc]h}t|tjjrt j |n,t j tj |tjc}|_d|_ ycc}wri) rtrTrrrrr rVr\rj)r]rHsegs r`rGzLineCollection.set_segmentsjsl   #+,+5S"%%:K:K*Luzz#!JJrzz#u'=>?,  ,sA-Bcg}|jD]L}|jdDcgc]\}}| }}}tj|}|j |N|Scc}}w)z Returns ------- list List of segments in the LineCollection. Each list item contains an array of vertices. F)simplify)r\ iter_segmentsrTr r)r]rHrvertex_rs r` get_segmentszLineCollection.get_segmentsvsuKK &D%%u%5 FAHzz(+H OOH % &s A c(tjdS)Nzlines.linewidthrres r`rz%LineCollection._get_default_linewidths||-..rac(tjdS)Nzlines.antialiasedrres r`rz'LineCollection._get_default_antialiaseds||/00rac(tjdS)Nz lines.colorrres r`r9z%LineCollection._get_default_edgecolors||M**racy)Nrrres r`r(z%LineCollection._get_default_facecolorsractt|||j|j|jyyrc)r6rDr= set_gapcolor_original_gapcolor)r]rCr_s r`rDzLineCollection.set_alphas3 % >> %   d55 6 &rac&|j|y)aH Set the edgecolor(s) of the LineCollection. Parameters ---------- c : :mpltype:`color` or list of :mpltype:`color` Single color (all lines have same color), or a sequence of RGBA tuples; if it is a sequence the lines will cycle through the sequence. N)rHr$s r`r&zLineCollection.set_colors 1rac|jSrc)r7res r` get_colorzLineCollection.get_colorrprac4||_|j|y)a1 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 list of :mpltype:`color` or None The color with which to fill the gaps. If None, the gaps are unfilled. N)rW _set_gapcolorr]gapcolors r`rVzLineCollection.set_gapcolors$#+ 8$racd| tj||j}||_d|_yri)rAr*r+r=rjr]s r`r\zLineCollection._set_gapcolors,  ,,Xt{{CH! rac|jSrc)r=res r` get_gapcolorzLineCollection.get_gapcolorr5rac Ht|jtj|jDcgc]W\}}|dk(r9t j tjdtj|fn|tj|fY}}}t|Scc}}w)a% Returns the path and pattern for the gaps in the non-solid lines. This path and pattern is the inverse of the path and pattern used to construct the non-solid lines. For solid lines, we set the inverse path to nans to prevent drawing an inverse line. r3r) rr\ itertoolscycler:rrrTfullrr_get_inverse_dash_pattern)r]rr path_patternss r`rz,LineCollection._get_inverse_paths_linestyless  Y__T-=-=> ? ArYZZ/ 0" 5 633R8 9 :A AM""AsAB)rr[r\r]r;r7rGrrlrPrrr9r(rDr& set_colorsrZ get_colorsrVr\rarrbrcs@r`rDrD*su"M*$XII0/1+7 J J%* #rarDceZdZdZdZ ddddddddfd Zd Zd Zd ZexZ Z d Z d Z dZ dZdZdZdZdZfdZfdZdZxZS)EventCollectionz A collection of locations along a single axis at which an "event" occurred. The events are given by a 1-dimensional array. They do not have an amplitude and are displayed as parallel lines. TrrNr)) lineoffset linelengthr#rr"rc t |gf||||d| d|_||_||_|j ||j |y)aY Parameters ---------- positions : 1D array-like Each value is an event. orientation : {'horizontal', 'vertical'}, default: 'horizontal' The sequence of events is plotted along this direction. The marker lines of the single events are along the orthogonal direction. lineoffset : float, default: 0 The offset of the center of the markers from the origin, in the direction orthogonal to *orientation*. linelength : float, default: 1 The total height of the marker (i.e. the marker stretches from ``lineoffset - linelength/2`` to ``lineoffset + linelength/2``). linewidth : float or list thereof, default: :rc:`lines.linewidth` The line width of the event lines, in points. color : :mpltype:`color` or list of :mpltype:`color`, default: :rc:`lines.color` The color of the event lines. linestyle : str or tuple or list thereof, default: 'solid' Valid strings are ['solid', 'dashed', 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples should be of the form:: (offset, onoffseq), where *onoffseq* is an even length tuple of on and off ink in points. antialiased : bool or list thereof, default: :rc:`lines.antialiased` Whether to use antialiasing for drawing the lines. **kwargs Forwarded to `.LineCollection`. Examples -------- .. plot:: gallery/lines_bars_and_markers/eventcollection_demo.py )rrr rTN)r6r7_is_horizontal _linelength _lineoffsetset_orientation set_positions) r] positions orientationrlrmr#rr"rr^r_s r`r7zEventCollection.__init__sd`  #$-) %K #" ##%% [) 9%racz|jrdnd}|jDcgc] }|d|f c}Scc}w)zX Return an array containing the floating-point values of the positions. rr) is_horizontalrP)r]possegments r` get_positionszEventCollection.get_positions(s;%%'aQ/3/@/@/BCG3CCCs8c|g}tj|dk7r td|j}|j }|j rdnd}tj t|ddf}tj|dddf|dddd|f<||dz z|dddd|z f<||dz z |dddd|z f<|j|y)z Set the positions of the events.Nrz!positions must be one-dimensionalrr5) rTrQrget_lineoffsetget_linelengthrwr^rsortrG)r]rtrlrmpos_idxrHs r`rszEventCollection.set_positions/s  I 779  "@A A((* ((* ))+!88S^Q23"$'')"4QW"=Aw&0:>&AAq7{"#&0:>&AAq7{"# (#rac|t|drt|dk(ry|j}tj|tj |g}|j |y)z2Add one or more events at the specified positions.Nrr)rvrrzrThstackrUrs)r]positionrts r` add_positionszEventCollection.add_positions>sX  % 8 #H  2 &&( IIy"--*ABC  9%rac|jS)z=True if the eventcollection is horizontal, False if vertical.)rores r`rwzEventCollection.is_horizontalHs"""rac*|jrdSdS)zX Return the orientation of the event line ('horizontal' or 'vertical'). horizontalvertical)rwres r`get_orientationzEventCollection.get_orientationLs $113|CCrac|j}t|D]\}}tj|||<|j ||j |_d|_y)zv Switch the orientation of the event line, either from vertical to horizontal or vice versus. TN)rP enumeraterTfliplrrGrwrorj)r]rHirys r`switch_orientationz"EventCollection.switch_orientationRse $$&#H- -JAw))G,HQK - (#"&"4"4"66 ractjddd|}||jk(ry|jy)z Set the orientation of the event line. Parameters ---------- orientation : {'horizontal', 'vertical'} TF)rr)ruN)r check_getitemrwr)r]rurws r`rrzEventCollection.set_orientation^sA**U 3#%  D..0 0  !rac|jS)z7Return the length of the lines used to mark each event.)rpres r`r}zEventCollection.get_linelengthmrac||jk(ry|j}|j}|jrdnd}|D]}||dz z|d|f<||dz z |d|f<|j |||_y)z4Set the length of the lines used to mark each event.Nrr@)r}r|rPrwrGrp)r]rmrlrHrxrys r`set_linelengthzEventCollection.set_linelengthq ,,. . ((* $$&%%'aQ ;G(:?:GAsFO(:?:GAsFO ; (#%rac|jS)z7Return the offset of the lines used to mark each event.)rqres r`r|zEventCollection.get_lineoffset~rrac||jk(ry|j}|j}|jrdnd}|D]}||dz z|d|f<||dz z |d|f<|j |||_y)z4Set the offset of the lines used to mark each event.Nrrr)r|r}rPrwrGrq)r]rlrmrHrxrys r`set_lineoffsetzEventCollection.set_lineoffsetrrac&t|dS)z3Get the width of the lines used to mark each event.rr6rFr]r_s r`rFzEventCollection.get_linewidthsw$&q))rac t|Srcrrs r`rzEventCollection.get_linewidthssw$&&rac(|jdS)z6Return the color of the lines used to mark each event.r)rires r`rZzEventCollection.get_colors ##ra)r)rr[r\r]r;r7rzrsrextend_positionsappend_positionsrwrrrrr}rr|rrFrrZrbrcs@r`rkrksM*8&"!8&tD $&+87'#D  "  &  &*'$rarkc@eZdZdZej dzZfdZxZS)CircleCollectionz-A collection of circles, drawn using splines.r+c t|di||j||jt j t jjg|_ y)z Parameters ---------- sizes : float or array-like The area of each circle in points^2. **kwargs Forwarded to `.Collection`. Nr) r6r7rrr1rrsrr unit_circler\)r]ror^r_s r`r7zCircleCollection.__init__sO "6" u :779:zz--/0 ra) rr[r\r]rTr<rnr7rbrcs@r`rrs7eeoG 1 1rarczeZdZdZddfd ZdZdZdZdZd Z d Z d Z e jfd ZxZS) EllipseCollectionz.A collection of ellipses, drawn using splines.points)unitsc Zt|di||j||j||j |||_|j tjtjd|_ tjjg|_y)a Parameters ---------- widths : array-like The lengths of the first axes (e.g., major axis lengths). heights : array-like The lengths of second axes. angles : array-like The angles of the first axes, degrees CCW from the x-axis. units : {'points', 'inches', 'dots', 'width', 'height', 'x', 'y', 'xy'} The units in which majors and minors are given; 'width' and 'height' refer to the dimensions of the axes, while 'x' and 'y' refer to the *offsets* data units. 'xy' differs from all others in that the angle as plotted varies with the aspect ratio, and equals the specified angle only when the aspect ratio is unity. Hence it behaves the same as the `~.patches.Ellipse` with ``axes.transData`` as its transform. **kwargs Forwarded to `Collection`. r'Nr)r6r7 set_widths set_heights set_angles_unitsr1rrsrTr^rnrrrr\)r]widthsheightsanglesrr^r_s r`r7zEllipseCollection.__init__s* "6"  !   :779:88I.zz--/0 rac|j}|jd}|jdk(rd}n+|jdk(r.|jj|j jz }n|jdk(r.|jj |j j z }n|jdk(r |j}n|jdk(r|jd z }nv|jd k(r|jj}nP|jd k(r|jj }n*|jd k(rd }ntd|jtjt|jddf|_ |j|z}|j|z}tj|j }tj"|j }||z|jddddf<|| z|jddddf<||z|jddddf<||z|jddddf<d |jddddf<t$j&}|jdk(rY|j(j+j-j/} d| ddddf<|j1|| yy)z0Calculate transforms immediately before drawing.FrrrrrinchesrrkrrdotsrfzUnrecognized units: r(Nrr5)rwrrrrviewLimrrprrTrr_widthsrn_heightssin_anglescosrrrrr:copyr1) r]axfigscrr sin_angle cos_angle_affinems r`_set_transformsz!EllipseCollection._set_transformssPYYoo5o) ;;$ B [[C !1!11B [[C "**"3"33B [[H $B [[H $4B [[G #B [[H $B [[F "B3DKK?CD D88S%61$=>"--"$FF4<<( FF4<<( $*Y$6Aq!$+yj$8Aq!$*Y$6Aq!$+i$7Aq!$'Aq!%% ;;$  '')446;;=AAbqb!"fI   wqz * rachdtj|jz|_d|_y)z5Set the lengths of the first axes (e.g., major axis).?TN)rTr ravelrrj)r]rs r`rzEllipseCollection.set_widthss'RZZ/5577  rachdtj|jz|_d|_y)2Set the lengths of second axes (e.g., minor axes).rTN)rTr rrrj)r]rs r`rzEllipseCollection.set_heightss'bjj17799  racbtj|j|_d|_y)z>Set the angles of the first axes, degrees CCW from the x-axis.TN)rTdeg2radrrrj)r]rs r`rzEllipseCollection.set_angless"zz&)//1  rac |jdzS)z5Get the lengths of the first axes (e.g., major axis).r5)rres r` get_widthszEllipseCollection.get_widths s||arac |jdzS)rr5)rres r` get_heightszEllipseCollection.get_heights s}}q  rac@tj|jS)z>Get the angles of the first axes, degrees CCW from the x-axis.)rTrad2degrres r` get_angleszEllipseCollection.get_anglesszz$,,''racD|jt| |yrc)rr6rrus r`rzEllipseCollection.draws   Xra)rr[r\r]r7rrrrrrrrr`rrbrcs@r`rrsL89A1<(+T    !(  rarc.eZdZdZddfd ZdZxZS)PatchCollectionz A generic collection of patches. PatchCollection draws faster than a large number of equivalent individual Patches. It also makes it easier to assign a colormap to a heterogeneous collection of patches. F)match_originalc |rd}|Dcgc] }|| c}|d<|Dcgc]}|jc}|d<|Dcgc]}|jc}|d<|Dcgc]}|jc}|d<|Dcgc]}|jc}|d<t |di||j |ycc}wcc}wcc}wcc}wcc}w) a? Parameters ---------- patches : list of `.Patch` A sequence of Patch objects. This list may include a heterogeneous assortment of different patch types. match_original : bool, default: False If True, use the colors and linewidths of the original patches. If False, new colors may be assigned by providing the standard collection arguments, facecolor, edgecolor, linewidths, norm or cmap. **kwargs All other parameters are forwarded to `.Collection`. If any of *edgecolors*, *facecolors*, *linewidths*, *antialiaseds* are None, they default to their `.rcParams` patch setting, in sequence form. Notes ----- The use of `~matplotlib.cm.ScalarMappable` functionality is optional. If the `~matplotlib.cm.ScalarMappable` matrix ``_A`` has been set (via a call to `~.ScalarMappable.set_array`), at draw time a call to scalar mappable will be made to set the face colors. cJ|jr|jSgdS)N)rrrr)rWr)patchs r`determine_facecolorz5PatchCollection.__init__..determine_facecolorBs!>># ..00##rarrrrrNr)rrFrHrr6r7rl)r]patchesrr^rrr_s r`r7zPatchCollection.__init__$s:  $ EL#Lq$7$:#LF< ?F#G!AOO$5#GF< ?F#G!AOO$5#GF< ?F#G!AOO$5#GF< CJ%Kaa&7&7&9%KF> " "6" w$M#G#G#G%KsCC C&CCc|Dcgc]/}|jj|j1}}||_ycc}wrc)r|transform_pathget_pathr\)r]rrrks r`rlzPatchCollection.set_pathsQsC!#"11!**,?## #s4A)rr[r\r]r7rlrbrcs@r`rrs38+ ZrarcbeZdZdZfdZdZdZedZe jdZ xZ S)TriMeshz Class for the efficient drawing of a triangular mesh using Gouraud shading. A triangular mesh is a `~matplotlib.tri.Triangulation` object. c Rt|di|||_d|_tj j |_tj|jjdd|jjddf}|jj|y)Ngouraudrrr)r6r7_triangulation_shadingrr~unitrrTrrrUrr)r] triangulationr^rr_s r`r7zTriMesh.__init__]s "6"+! __))+ YY //A6%//A689 &&r*racR|j|j|jSrcr\rlres r`rfzTriMesh.get_pathsj ;;  NN {{racD|j|j|_yrc)convert_mesh_to_pathsrr\res r`rlzTriMesh.set_pathsos001D1DE rac|j}tj|j||j|fd}|Dcgc]}t j |c}Scc}w)z Convert a given mesh into a sequence of `.Path` objects. This function is primarily of use to implementers of backends that do not directly support meshes. rr)get_masked_trianglesrTrrrrr)tri trianglesrrs r`rzTriMesh.convert_mesh_to_pathsrsU,,. #%% *CEE),<=BG',-! 1 ---sA'c|jsy|j|jj|j |j }|j }|j}tj|j||j|fd}|j|j|}|j}|j||j!|j#d|j%||||j'|j)|j+|jjy)N)gidrrr)rrr_rrr|rrrTrrrrr,rrrIrFdraw_gouraud_trianglesrrr)r]rrrrrr rs r`rz TriMesh.draw~s! DNN33H&&( !!,,. #%% *CEE),<=BG ""$!!), __  " ++-a01''E69;K;K;MN T^^445ra) rr[r\r]r7rfrlrarrr`rrbrcs@r`rrWsF + F . . 6 6rarc^eZdZdZdddZfdZdZfdZfdZe d Z d Z xZ S) rRa Class for managing the two dimensional coordinates of Quadrilateral meshes and the associated data with them. This class is a mixin and is intended to be used with another collection that will implement the draw separately. A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is defined by the vertices :: (m+1, n) ----------- (m+1, n+1) / / / / / / (m, n) -------- (m, n+1) The mesh need not be regular and the polygons need not be convex. Parameters ---------- coordinates : (M+1, N+1, 2) array-like The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates of vertex (m, n). shading : {'flat', 'gouraud'}, default: 'flat' flat)shadingcNtjd|||_||_y)N)NNr5 coordinates)r check_shape _coordinatesr)r]rrs r`r7z_MeshData.__init__s! kB' rac|jjdd\}}|jdk(r |dz |dz }}n||}}||df||df||f||zfg}|dtj|}||vrKt d|d|d |jd d j t t|d |j t|%|S) au Set the data values. Parameters ---------- A : array-like The mesh data. Supported array shapes are: - (M, N) or (M*N,): a mesh with scalar data. The values are mapped to colors using normalization and a colormap. See parameters *norm*, *cmap*, *vmin*, *vmax*. - (M, N, 3): an image with RGB values (0-1 float or 0-255 int). - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), i.e. including transparency. If the values are provided as a 2D grid, the shape must match the coordinates grid. If the values are 1D, they are reshaped to 2D. M, N follow from the coordinates grid, where the coordinates grid shape is (M, N) for 'gouraud' *shading* and (M+1, N+1) for 'flat' shading. rrrrr(zFor X (z ) and Y (z) with z shading, A should have shape z or z, not ) rrWrrTrjoinrr1r6 set_array) r]Arrrw ok_shapesrWr_s r`rz_MeshData.set_arrays,))//"5  ==F "A:uqyqA5qAAYAq Aq6AE8< =HHQKEI% eWIfXWT]]OL4{{3sI#678qwwiIJJw ##rac|jS)a Return the vertices of the mesh as an (M+1, N+1, 2) array. M, N are the number of quadrilaterals in the rows / columns of the mesh, corresponding to (M+1, N+1) vertices. The last dimension specifies the components (x, y). )rres r`get_coordinatesz_MeshData.get_coordinatess   rac@t|jddSNrr)r6rrUrs r`rz_MeshData.get_edgecolor w$&..r155rac@t|jddSr)r6rrUrs r`rz_MeshData.get_facecolorrrac ht|tjjr |j}n|}tj |ddddf|ddddf|ddddf|ddddf|ddddfgdj d}|Dcgc]}tj|c}Scc}w)z Convert a given mesh into a sequence of `.Path` objects. This function is primarily of use to implementers of backends that do not directly support quadmeshes. Nrrr5r)rrr5) rtrTrrdatarrUrr)rr%rrs r`_convert_mesh_to_pathsz _MeshData._convert_mesh_to_pathss k255#4#4 5  AA crc3B3hK crc12gJ ab!"fI ab#2#gJ crc3B3hK !   7:& (..! 1 ...sB/cjt|tjjr |j}n|}|ddddf}|ddddf}|ddddf}|ddddf}||z|z|zdz }tj ||||||||||||g dj d}|jj g|jddd} |j} tjj| r | jnd} | tj| | d f<| ddddf} | ddddf} | ddddf}| ddddf}| | z|z|zdz }tj | | || ||||||| |g dj d }tj|d }||||fS) z Convert a given mesh into a sequence of triangles, each point with its own color. The result can be used to construct a call to `~.RendererBase.draw_gouraud_triangles`. Nrrg@r5r)rr(r5rr()rr(r).r5r()rtrTrrrrrUrrWrrrrisnan)r]rrp_ap_bp_cp_dp_centerrr%zrc_ac_bc_cc_dc_centerr tmasks r`_convert_mesh_to_trianglesz$_MeshData._convert_mesh_to_triangles s k255#4#4 5  AASbSkQRjABiCRCj#IOc)S0NN h h h h $   7:&     ( ()D;+<+G#..0J __  DMMO$ " ++-a01 ==I % $ ? ? L Iv  + +Ivy'7'7'9 ;  # #I$$&!!!$q(+*;*;A*>*BWj""$,,W5!!4#6#6#8#@#@#I  K T^^445 rac|j|\}}|r4|j$|jj|dSy)Nr)rrr)r]event containedinfos r`get_cursor_datazQuadMesh.get_cursor_data sE--. 4 )5>>#))+DK8 8ra) rr[r\r]r7rfrlrrr`rr'rbrcs@r`rr0 sEB48 " M . .`rarcLeZdZdZfdZdZdZfdZfdZfdZ xZ S) PolyQuadMeshas Class for drawing a quadrilateral mesh as individual Polygons. A quadrilateral mesh is a grid of M by N adjacent quadrilaterals that are defined via a (M+1, N+1) grid of vertices. The quadrilateral (m, n) is defined by the vertices :: (m+1, n) ----------- (m+1, n+1) / / / / / / (m, n) -------- (m, n+1) The mesh need not be regular and the polygons need not be convex. Parameters ---------- coordinates : (M+1, N+1, 2) array-like The vertices. ``coordinates[m, n]`` specifies the (x, y) coordinates of vertex (m, n). Notes ----- Unlike `.QuadMesh`, this class will draw each cell as an individual Polygon. This is significantly slower, but allows for more flexibility when wanting to add additional properties to the cells, such as hatching. Another difference from `.QuadMesh` is that if any of the vertices or data of a cell are masked, that Polygon will **not** be drawn and it won't be in the list of paths returned. c vt||tj|fdgi||jy)Nrr)r6r7r_set_unmasked_verts)r]rr^r_s r`r7zPolyQuadMesh.__init__ s9 [19B9&9   "rac8tjtjj|jd}|ddddf|ddddfz|ddddfz|ddddfz}|j }|tjj|}|j dk(r|tj|dz}|S|j dk(r||z}|S||j|jddddddfjddz}|S)z8Get the unmasked regions using the coordinates and arrayrrrrNr(r5) rTrrrrrrQrUrW)r]rrs r`_get_unmasked_polysz PolyQuadMesh._get_unmasked_polys s'vvbee(():):;"EQrT1R4Z 4AB</$qtQRx.@4AbD>Qnn ?%%$$S)Cxx1}s,, u Q u  D$5$5crc3B3k$B$H$H!$LMMu rac |jd}|jd}|j}tjj |ddddf|}tjj |ddddf|}tjj |ddddf|}tjj |ddddf|}tjj |ddddf|}tjj |ddddf|} tjj |ddddf|} tjj |ddddf|} t |} tjj |||||| | | ||g d} | j| ddf}|j|y)N).r).rrrrrr5) rr-rTrrrrrUr)r]XYunmaskX1Y1X2Y2X3Y3X4Y4npolyrrs r`r+z PolyQuadMesh._set_unmasked_verts s   f %   f %))+ UU\\!CRC"H+ &v . UU\\!CRC"H+ &v . UU\\!ABG* %f - UU\\!ABG* %f - UU\\!ABF) $V , UU\\!ABF) $V , UU\\!CRCG* %f - UU\\!CRCG* %f -B UU[["b"b"b"b"bA[ K E1a=) uract|}|jj}t |t |k7r|S||ddfSrc)r6rr-rr)r]runmasked_polysr_s r`rzPolyQuadMesh.get_edgecolor OW " $11399; r7c.) )I.!#$$ract|}|jj}t |t |k7r|S||ddfSrc)r6rr-rr)r]rr<r_s r`rzPolyQuadMesh.get_facecolor r=rac|j}t| |tj||js|j yyrc)r-r6rrT array_equalr+)r]r prev_unmaskr_s r`rzPolyQuadMesh.set_array sI..0  !~~k4+C+C+EF  $ $ &Gra) rr[r\r]r7r-r+rrrrbrcs@r`r)r) s,@#&& % %''rar))3r]rcrrnumbersrrrnumpyrT matplotlibrCrrrrr r mcolorizerr rAr r rrrrrr_enumsrrdefine_aliasesColorizingArtistr&rerwrrr*r>rArDrkrrrrrRrr)rrar`rIs  XXXX' "D)%%/%& ],,]]@,:,^e)ePN)Nbo@o@d?(0?(D313 7 57 w#Zw#tt$nt$n1+1(i iX9j9x<6j<6~W1W1tny*nbl'9nl'ra