rL iUddlmZddlZddlZddlZddlmZmZddl m Z ddl m Z ddlmZddlmZGddej(ZGddZGd d eZy) )MutableMappingN)_api _docstring)allow_rasterizationceZdZdZdZej fdZdZdZ dZ dZ fdZ dfd Z d Zd Zd Zd ZdZdZefdZdZdZdZddZdZedZedZedZdZxZ S)Spineay An axis spine -- the line noting the data area boundaries. Spines are the lines connecting the axis tick marks and noting the boundaries of the data area. They can be placed at arbitrary positions. See `~.Spine.set_position` for more information. The default position is ``('outward', 0)``. Spines are subclasses of `.Patch`, and inherit much of their behavior. Spines draw a line, a circle, or an arc depending on if `~.Spine.set_patch_line`, `~.Spine.set_patch_circle`, or `~.Spine.set_patch_arc` has been called. Line-like is the default. For examples see :ref:`spines_examples`. cy)Nrselfs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/spines.py__str__z Spine.__str__ sc t|d i|||_|j|jj d||_|j d|jtjd|jtjd|jdd|_ |jd|j|jjd|_d|_t%j&t(j*| ||_d |_t1j2|_y) a Parameters ---------- axes : `~matplotlib.axes.Axes` The `~.axes.Axes` instance containing the spine. spine_type : str The spine type. path : `~matplotlib.path.Path` The `.Path` instance used to draw the spine. Other Parameters ---------------- **kwargs Valid keyword arguments are: %(Patch:kwdoc)s Frootnonezaxes.edgecolorzaxes.linewidth projectingNg@)pathliner )super__init__axes set_figure get_figure spine_type set_facecolor set_edgecolormplrcParams set_linewidth set_capstyleaxis set_zorder set_transform transData_bounds _positionrcheck_isinstancempathPath_path _patch_type mtransformsIdentityTransform_patch_transform)r rrrkwargs __class__s r rzSpine.__init__#s& "6"   ,,%,89$ 6" 3<<(89: 3<<(89: ,'   499../  ejjt4 "!, = = ?rcd|_||_|dz|_|dz|_||_||_t jj|||_ |j|jjd|_ y)zSet the spine to be arc-like.arcTN)r-_center_width_height_theta1_theta2r*r+r4r,r%r transAxesstale)r centerradiustheta1theta2s r set_patch_arczSpine.set_patch_arcXsj  qj z   ZZ^^FF3  499../ rcd|_||_|dz|_|dz|_|j |j j d|_y)zSet the spine to be circular.circler5TN)r-r6r7r8r%rr;r<)r r=r>s r set_patch_circlezSpine.set_patch_circleesF# qj z  499../ rc d|_d|_y)zSet the spine to be linear.rTN)r-r<r s r set_patch_linezSpine.set_patch_lineos! rc|jdvsJ|j|jd|j|jdf}|j|j}|j|j }t jj|dz|dzj||_ y)a! Notes ----- This cannot be called until after this has been added to an Axes, otherwise unit conversion will fail. This makes it very important to call the accessor method and not directly access the transformation member variable. r4rCr?N) r-convert_xunitsr6convert_yunitsr7r8r.Affine2Dscale translater0)r r=widthheights r _recompute_transformzSpine._recompute_transformus#4444%%dll1o6%%dll1o68##DKK0$$T\\2! 4 4 6 U53; - Y! rct|jdvr|j|jSt|S)NrH)r-rRr0rget_patch_transform)r r2s r rTzSpine.get_patch_transforms8   0 0  % % '(( (7.0 0rc|jt| |}|j|jj s|S|g}|jj }t th|h|jjzd}t th|h|jjzd}||fD]}||j}|j} |j} | dk(rd} d} n| dk(rd} d} nd} d} |jd j} | | zd z | z} | | zd z | z} |jj ro|j d k(r)|j"| z |_|j$| z|_n7|j d k(r(|j&| z |_|j(| z|_|j*j ro|j d k(r)|j$| z|_|j"| z |_n7|j dk(r(|j(| z|_|j&| z |_|j-|t.j0j3|S)a Return the window extent of the spines in display space, including padding for ticks (but not their labels) See Also -------- matplotlib.axes.Axes.get_tightbbox matplotlib.axes.Axes.get_window_extent )rendererNoutrIrinrJTrHleftbottomrighttop)_adjust_locationrget_window_extentr# get_visible _update_ticksnextiter majorTicks minorTicksfrozen_size_tickdirrdpi tick1linerx0x1y0y1 tick2lineappendr.Bboxunion)r rVbbbboxes drawn_ticks major_tick minor_ticktickbb0tickltickdirpadoutpadinrir2s r r_zSpine.get_window_extents?  W & & 9 99 DII$9$9$;Iii--/ $~~0G$))2F2F0GGH$O $~~0G$))2F2F0GGH$O ," D|))+CJJEmmG%D//t/,00Ce^b(3.FEMB&,E~~))+??f, VVf_CF VVe^CF__0 VVf_CF VVe^CF~~))+??g- VVf_CF VVe^CF__- VVf_CF VVf_CF MM# E" H%%f--rc|jSN)r,r s r get_pathzSpine.get_path zzrcb|j#d|_|j|jyy)N)outward)r( set_positionr s r _ensure_position_is_setzSpine._ensure_position_is_sets* >> !-DN   dnn - "rc ||_d|_y)z Register an axis. An axis should be registered with its corresponding spine from the Axes instance. This allows the spine to clear any axis properties when needed. TN)r#r<)r r#s r register_axiszSpine.register_axiss  rcr|j|j|jjyy)zClear the current spine.N)_clearr#clearr s r rz Spine.clears( 99 IIOO  !rcd|_y)z Clear things directly related to the spine. In this way it is possible to avoid clearing the Axis as well when calling from library code where it is known that the Axis is cleared separately. N)r(r s r rz Spine._clears rc|jdk(ry|j|j\}}n||jdvr$|jjj\}}nJ|jdvr$|jjj \}}nt d|j|jdk(r|jdvr\ |jj} |jj}||z|z}||z|z}||kDr||}}tjjtj|tj||_|jd k(r|j"t%j&}n|j"j)}|j+|jjj\}} |jj-}|j+|}||z ||z z } | |_| |_yt d |jzy|j j2} | j4d k(sJd |jdvr || d<|| d<y|jdvr || d<|| d<yt d |jz#t$rd}YwxYw#t$rd }YwxYw#t$r|}YwxYw)z4Automatically set spine bounds to the view interval.rCNrZr\r]r[unknown spine spine_type: r4r[r]rIrr[z#unable to set bounds for spine "%s")r5r5zunexpected vertices shaperrI)rIrI)rrrIr)rr'rviewLim intervaly intervalx ValueErrorr-get_theta_directionAttributeErrorget_theta_offsetr*r+r4nprad2degr,r#r.r/ get_transform transform get_roriginr8r7verticesshape) r lowhigh directionoffsettrrminrmaxroriginscaled_diameterv1s r r^zSpine._adjust_locations ??h &  << # IC __ 1 1 ))33IC __ 1 1 ))33IC9$//9JKL L   u $"33" $ = = ?I!YY779FIo.i'&0: $cC"ZZ^^BJJsORZZ=MN ??h.yy((::<!YY446!#dii.?.?.I.I!JJD$8"&))"7"7"9#%,,w"7'+g~$.&IO#2DL"1DK!!F!%"122#/($$B88v% B'B B%"3344$5544 !F!%"122U&" !I"&F"*'"&'s6 J3$KK3 KK KK K%$K%cT|jt| |}d|_|S)NF)r^rdrawr<)r rVretr2s r rz Spine.draw+s) gl8$  rc |dvrn+t|dk7r td|ddvr td||_|j|j |j |j j d|_y) a Set the position of the spine. Spine position is specified by a 2 tuple of (position type, amount). The position types are: * 'outward': place the spine out from the data area by the specified number of points. (Negative values place the spine inwards.) * 'axes': place the spine at the specified Axes coordinate (0 to 1). * 'data': place the spine at the specified data coordinate. Additionally, shorthand notations define a special positions: * 'center' -> ``('axes', 0.5)`` * 'zero' -> ``('data', 0.0)`` Examples -------- :doc:`/gallery/spines/spine_placement_demo` )r=zeror5z&position should be 'center' or 2-tupler)rrdataz:position[0] should be one of 'outward', 'axes', or 'data' NT)lenrr(r%get_spine_transformr# reset_ticksr<)r positions r rzSpine.set_position2s* ) ) 8}! !IJJ{"== "677! 43356 99 II ! ! # rc:|j|jS)zReturn the spine position.)rr(r s r get_positionzSpine.get_positionUs $$&~~rcp|j|j}t|tr|dk(rd}n|dk(rd}t |dk(sJd|\}}t j gd||jd vr|jjd }nC|jd vr|jjd }ntd |j|dk(rj|dk(r|Sddddd|j}|tj|zdz }|tjg||j!dj"zS|dk(rk|jd vr'tj$j'dddd|d|zS|jdvr'tj$j'ddddd||zSy|dk(r|jdvr|dz}|jd vrctj(tj$j+|d|jj,z|jj,S|jdvrctj(|jj,tj$j+d||jj,zSyy)zReturn the spine transform.r=)rrJr)rrr5zposition should be 2-tuple)rrr) position_typergrid)whichrrrr)rr)rrr)rZr\r[r]rYFrrrIrr)r\r]N)rr( isinstancestrrr check_in_listrrget_yaxis_transformget_xaxis_transformrrarrayr.ScaledTranslationrdpi_scale_transrM from_valuesblended_transform_factoryrOr&)r rramountbase_transform offset_vec offset_dotss r rzSpine.get_spine_transformZs $$&>> h $8#(V#&8}!?#??! ( v 6)6 8 ??/ /!YY:::HN __ 1 1!YY:::HN9$//9LMN N I %{%%&-(/ $1 %rxx ';;b@ &%77W(W*.//u/*E*U*UWWXf $"33#,,88Aq!VQO()*$55#,,88Aq!QO()*6f $"22! "33"<<((*44VQ?ii))*II''))$55"<<II''((*44Q?ii))*++6%rc|jdk(r td|tj|r|\}}|j xsd\}}||}||}||f|_d|_y)a Set the spine bounds. Parameters ---------- low : float or None, optional The lower spine bound. Passing *None* leaves the limit unchanged. The bounds may also be passed as the tuple (*low*, *high*) as the first positional argument. .. ACCEPTS: (low: float, high: float) high : float or None, optional The higher spine bound. Passing *None* leaves the limit unchanged. rCz5set_bounds() method incompatible with circular spinesNNNT)rrriterable get_boundsr'r<)r rrold_lowold_highs r set_boundszSpine.set_boundssw" ??h &GI I r?r@r1rrs r arc_spinezSpine.arc_spinesDzz~~ff-T:t6v6VVVV< rc tjj}d}||||fi|}|j|||S)z%Create and return a circular `Spine`.rC)r*r+ unit_circlerD)rrr=r>r1rrrs r circular_spinezSpine.circular_spinesCzz%%' T:t6v6/ rc4|j|d|_y)aW Set the edgecolor. Parameters ---------- c : :mpltype:`color` Notes ----- This method does not modify the facecolor (which defaults to "none"), unlike the `.Patch.set_color` method defined in the parent class. Use `.Patch.set_facecolor` to set the facecolor. TN)rr<)r cs r set_colorzSpine.set_colors 1 rrr)!__name__ __module__ __qualname____doc__rrinterpdrrArDrFrRrTr_rrrrrr^rrrrrrr classmethodrrrr __classcell__)r2s@r rrs"2@2@h   $18.t.  >2@ !F 9+v<$rrc"eZdZdZdZdZdZy) SpinesProxyag A proxy to broadcast ``set_*()`` and ``set()`` method calls to contained `.Spines`. The proxy cannot be used for any other operations on its members. The supported methods are determined dynamically based on the contained spines. If not all spines support a given method, it's executed only on the subset of spines that support it. c||_yr) _spine_dict)r spine_dicts r rzSpinesProxy.__init__s %rc |jjDcgc]}t||r|}}|dk7r|jdr|st d|dd}t j |||}|dj|_|Scc}w)Nsetset_z''SpinesProxy' object has no attribute ''c6|D]}t|||i|yr)getattr)_targets _funcnameargsr1spines r xz"SpinesProxy.__getattr__..xs'! ;)y)4:6: ;rr)rvalueshasattr startswithr functoolspartialr)r namerbroadcast_targetsrs r __getattr__zSpinesProxy.__getattr__s040@0@0G0G0I6u 't 4#66 EM$//&"9BS 9$qAC C ;   a!2D 9%a(00 6sB cg}|jjD]#}|jdt|D%t t t |S)Nc3BK|]}|jdr|yw)rN)r).0rs r z&SpinesProxy.__dir__.. s%L!4??63JLs)rrextenddirlistsortedr)r namesrs r __dir__zSpinesProxy.__dir__ s]%%,,. LE LLL%(ZL L LF3u:&''rN)rrrrrrr r rr rrs& (rrcVeZdZdZdZedZdZdZdZ dZ dZ d Z d Z d Zy ) Spinesa The container of all `.Spine`\s in an Axes. The interface is dict-like mapping names (e.g. 'left') to `.Spine` objects. Additionally, it implements some pandas.Series-like features like accessing elements by attribute:: spines['top'].set_visible(False) spines.top.set_visible(False) Multiple spines can be addressed simultaneously by passing a list:: spines[['top', 'right']].set_visible(False) Use an open slice to address all spines:: spines[:].set_visible(False) The latter two indexing methods will return a `SpinesProxy` that broadcasts all ``set_*()`` and ``set()`` calls to its members, but cannot be used for any other operation. c ||_yr_dict)r r1s r rzSpines.__init__(s  rc|di|SNr r )rds r from_dictzSpines.from_dict+s xQxrc|jSrrr s r __getstate__zSpines.__getstate__/rrc(|jdi|yr)r)r states r __setstate__zSpines.__setstate__2s rcZ |j|S#t$rtd|dwxYw)Nz$'Spines' object does not contain a 'z' spine)rKeyErrorr)r rs r rzSpines.__getattr__5sC F::d# # F 6tfGDF F Fs*ct|tru|Dcgc]}||jvs|}}|rtdj |t |jj Dcic] \}}||vr||c}}St|tr tdt|trD|j-|j!|jt |jStd|j|Scc}wcc}}w)Nz, z/Multiple spines must be passed as a single listzYSpines does not support slicing except for the fully open slice [:] to access all spines.) rrrrjoinritemstuplerslicestartstopstep)r keyk unknown_keysvs r __getitem__zSpines.__getitem__<s c4 '*B!atzz.AABLBtyy6771A1A1C -A#$8!"1 -. . c5 !NO O c5 !yy SXX%5#((:J"4::.. ;<<zz#C -sDD-D c"||j|<yrr)r r#values r __setitem__zSpines.__setitem__Ns 3rc|j|=yrr)r r#s r __delitem__zSpines.__delitem__Rs JJsOrc,t|jSr)rcrr s r __iter__zSpines.__iter__VsDJJrc,t|jSr)rrr s r __len__zSpines.__len__Ys4::rN)rrrrrrrrrrr'r*r,r.r0r rr r r sI,F$  rr )collections.abcrrnumpyr matplotlibrrrmatplotlib.artistrmatplotlib.transforms transformsr.matplotlib.patchespatchesmpatchesmatplotlib.pathrr*Patchrrr r rr r<sL*'1+%]HNN]@ ( (FI^Ir