rL ipdZddlmZddlZddlZddlmZmZddl m Z ddl m ZddlmZddlmZddlmZddlmZddlmZdd lmZmZmZmZd d lm Z Gd d Z!Gdde!eZ"GddejFZ$Gdde!e$Z%Gdde%Z&GddeZ'Gdde jPZ)y)aG The :mod:`.axis_artist` module implements custom artists to draw axis elements (axis lines and labels, tick lines and labels, grid lines). Axis lines and labels and tick lines and labels are managed by the `AxisArtist` class; grid lines are managed by the `GridlinesCollection` class. There is one `AxisArtist` per Axis; it can be accessed through the ``axis`` dictionary of the parent Axes (which should be a `mpl_toolkits.axislines.Axes`), e.g. ``ax.axis["bottom"]``. Children of the AxisArtist are accessed as attributes: ``.line`` and ``.label`` for the axis line and label, ``.major_ticks``, ``.major_ticklabels``, ``.minor_ticks``, ``.minor_ticklabels`` for the tick lines and labels (e.g. ``ax.axis["bottom"].line``). Children properties (colors, fonts, line widths, etc.) can be set using setters, e.g. :: # Make the major ticks of the bottom axis red. ax.axis["bottom"].major_ticks.set_color("red") However, things like the locations of ticks, and their ticklabels need to be changed from the side of the grid_helper. axis_direction -------------- `AxisArtist`, `AxisLabel`, `TickLabels` have an *axis_direction* attribute, which adjusts the location, angle, etc. The *axis_direction* must be one of "left", "right", "bottom", "top", and follows the Matplotlib convention for rectangular axis. For example, for the *bottom* axis (the left and right is relative to the direction of the increasing coordinate), * ticklabels and axislabel are on the right * ticklabels and axislabel have text angle of 0 * ticklabels are baseline, center-aligned * axislabel is top, center-aligned The text angles are actually relative to (90 + angle of the direction to the ticklabel), which gives 0 for bottom axis. =================== ====== ======== ====== ======== Property left bottom right top =================== ====== ======== ====== ======== ticklabel location left right right left axislabel location left right right left ticklabel angle 90 0 -90 180 axislabel angle 180 0 0 180 ticklabel va center baseline center baseline axislabel va center top center bottom ticklabel ha right center right center axislabel ha right center right center =================== ====== ======== ====== ======== Ticks are by default direct opposite side of the ticklabels. To make ticks to the same side of the ticklabels, :: ax.axis["bottom"].major_ticks.set_tick_out(True) The following attributes can be customized (use the ``set_xxx`` methods): * `Ticks`: ticksize, tick_out * `TickLabels`: pad * `AxisLabel`: pad ) methodcallerN)_apicbook)LineCollection)Line2D) PathPatch)Path)Affine2DBboxIdentityTransformScaledTranslation) AxislineStylec$eZdZdZfdZxZS)AttributeCopierctd)zz Return the underlying artist that actually defines some properties (e.g., color) of this artist. zget_ref_artist must overridden) RuntimeErrorselfs i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mpl_toolkits/axisartist/axis_artist.pyget_ref_artistzAttributeCopier.get_ref_artist^s ;<<cztd|z}|t}|dk(r||jS|S)Nget_auto)rsuperr)r attr_namegetterprop __class__s rget_attribute_from_ref_artistz-AttributeCopier.get_attribute_from_ref_artistes<fy01eg04vd))+,HDHr)__name__ __module__ __qualname__rr! __classcell__r s@rrr]s=IIrrc|eZdZdZddddZdZdZdZdZd Z d Z d Z d Z d Z dZeddgddggZdZy)TicksaW Ticks are derived from `.Line2D`, and note that ticks themselves are markers. Thus, you should use set_mec, set_mew, etc. To change the tick size (length), you need to use `set_ticksize`. To change the direction of the ticks (ticks are in opposite direction of ticklabels by default), use ``set_tick_out(False)`` N)axisc ||_g|_|j|||_|jd|vrd|d<d|vr d|vrd|d<t j |dgdgfi||j dy)NcolorrmewmarkeredgewidthT) _ticksizelocs_angles_labels set_tick_out_axisr__init__set_snap)rticksizetick_outr)kwargss rr3zTicks.__init__vs!"$ (# :: !f$"(wF"'8'F,2()rdRD3F3 drcH|jjdjSNr)r2 majorTicks tick1liners rrzTicks.get_ref_artistszz$$Q'111rcxtj|dstj|||_d|_y)Nr)r+T)r _str_equalmcolors_check_color_like_colorstale)rr+s r set_colorzTicks.set_colors0v.  % %E 2  rc$|jdSNr+r!rs r get_colorzTicks.get_color11'::rc$|jdS)NmarkeredgecolorrErs rget_markeredgecolorzTicks.get_markeredgecolor112CDDrc$|jdS)Nr-rErs rget_markeredgewidthzTicks.get_markeredgewidthrKrc||_y)z7Set whether ticks are drawn inside or outside the axes.N _tick_out)rbs rr1zTicks.set_tick_outs rc|jS)z:Return whether ticks are drawn inside or outside the axes.rOrs r get_tick_outzTicks.get_tick_out ~~rc||_y)z"Set length of the ticks in points.Nr/)rr5s r set_ticksizezTicks.set_ticksizes !rc|jS)z%Return length of the ticks in points.rVrs r get_ticksizezTicks.get_ticksizerTrc||_yN) locs_angles)rr\s rset_locs_angleszTicks.set_locs_angless &rr.?c V|jsy|j}|j|j|j |j |j |j|j}tj|j|j}|jr|jd|jD]\}}|j!t#j$|g}|j&r'|j&j(j*|ds^|j-||j.|tj|zt1||j3|j5y)Nr) get_visiblenew_gcset_foregroundrJ set_linewidthrM set_alpha_alpha get_transformr scalepoints_to_pixelsr/rS rotate_degr\transform_non_affinenparrayaxesviewLimcontains draw_markers_tickvert_pathr get_affinerestore)rrenderergc path_transmarker_transformlocanglelocss rdrawz Ticks.drawsL!  __  $2245 1134 T[[!'') $J"U8#<#  41$1&1 /rc||_y)a% Set the internal pad in points. The actual pad will be the sum of the internal pad and the external pad (the latter is set automatically by the `.AxisArtist`). Parameters ---------- pad : float The internal pad in points. Nr)rpads rset_padzAxisLabel.set_pad#s  rc|jS)z^ Return the internal pad in points. See `.set_pad` for more details. rrs rget_padzAxisLabel.get_pad1s yyrc.|jjSr[)r2labelrs rrzAxisLabel.get_ref_artist9szzrct|}|dk(r$|jjjS|jS)N __from_axes__)rget_textr2r_text)rtr s rrzAxisLabel.get_text=s; G    ::##,,. .zzr)rcenter)rrrrrrctj|j|\}}|j||j |y)z Set the default alignment. See `set_axis_direction` for details. Parameters ---------- d : {"left", "bottom", "right", "top"} dN)r check_getitem_default_alignmentsset_vaset_ha)rrvahas rset_default_alignmentzAxisLabel.set_default_alignmentIs6##D$<$<BB B Brr`rcd|jtj|j|y)z Set the default angle. See `set_axis_direction` for details. Parameters ---------- d : {"left", "bottom", "right", "top"} rN)rrr_default_anglesrrs rset_default_anglezAxisLabel.set_default_angleZs% $,,T-A-AQGHrcH|j||j|y)ah Adjust the text angle and text alignment of axis label according to the matplotlib convention. ===================== ========== ========= ========== ========== Property left bottom right top ===================== ========== ========= ========== ========== axislabel angle 180 0 0 180 axislabel va center top center bottom axislabel ha right center right center ===================== ========== ========= ========== ========== Note that the text angles are actually relative to (90 + angle of the direction to the ticklabel), which gives 0 for bottom axis. Parameters ---------- d : {"left", "bottom", "right", "top"} N)rrrs rrzAxisLabel.set_axis_directionds * ""1% q!rc$|jdSrDrErs rrFzAxisLabel.get_color|rGrc|jsy|j|j|jz|_t ||yr[)rarrirrrr|)rrur s rr|zAxisLabel.drawsI!    !:!:4<<>!J J   Xrc| |jdj}|jsy|j|j |j z}||_t|!|}|Sr) rrrarrirrrr)rrurbbr s rrzAxisLabel.get_window_extentsn  D1??AH!    !:!:4<<>!J J W &x 0 rr[)r"r#r$r}r3rrrrdictrrrrrrFr|rr%r&s@rrrs|.6D0  $8%6&7#79 !""#"$O I"0;  rrceZdZdZddfd ZdZdZdZdZe d d d d Z e d ddd Z dZ dZ ddZdZxZS) TickLabelsa Tick labels. While derived from `.Text`, this single artist draws all ticklabels. As in `.AxisLabel`, the position of the text is updated in the fly, so changing text position has no effect. Otherwise, the properties can be changed as a normal `.Text`. Unlike the ticklabels of the mainline Matplotlib, properties of a single ticklabel alone cannot be modified. To change the pad between ticks and ticklabels, use `~.AxisLabel.set_pad`. r)rc Tt|di||j|d|_y)Nrr~)rr3r_axislabel_pad)rrr7r s rr3zTickLabels.__init__s) "6" /rc<|jjdSr9)r2get_ticklabelsrs rrzTickLabels.get_ref_artistszz((*1--rcV|j||j|||_y)a Adjust the text angle and text alignment of ticklabels according to the Matplotlib convention. The *label_direction* must be one of [left, right, bottom, top]. ===================== ========== ========= ========== ========== Property left bottom right top ===================== ========== ========= ========== ========== ticklabel angle 90 0 -90 180 ticklabel va center baseline center baseline ticklabel ha right center right center ===================== ========== ========= ========== ========== Note that the text angles are actually relative to (90 + angle of the direction to the ticklabel), which gives 0 for bottom axis. Parameters ---------- label_direction : {"left", "bottom", "right", "top"} N)rr_axis_directionrlabel_directions rrzTickLabels.set_axis_directions(0 ""?3 /.rc\|j|j}|j|yr[)rrrrs rinvert_axis_directionz TickLabels.invert_axis_directions&66t7K7KL 0rc|j|}|syd}|j|j}}|dk(r+td|D}|dk(r|}||fS|dk(rd|z}||fS|dk(r+td|D}|dk(r|}||fS|dk(rd|z}||fS|d k(r_td |D}|d k(r|}||fS|dk(r d|z}||fS|d k(r+td |D}td |D} |}|| z}||fS|dk(r[td|D}|dk(r|}||fS|dk(r d|z}||fS|d k(r+td|D}td|D} | }|| z}|fS)a@ Calculate the ticklabel offsets from the tick and their total heights. The offset only takes account the offset due to the vertical alignment of the ticklabels: if axis direction is bottom and va is 'top', it will return 0; if va is 'baseline', it will return (height-descent). rrrrc3(K|] \}}}| ywr[r~.0whrs r z5TickLabels._get_ticklabels_offsets..0GAq!a0rg?rc3(K|] \}}}| ywr[r~rs rrz5TickLabels._get_ticklabels_offsets..rrrc3(K|] \}}}| ywr[r~rs rrz5TickLabels._get_ticklabels_offsets..rrbaselinec3.K|] \}}}||z ywr[r~rs rrz5TickLabels._get_ticklabels_offsets.. ?71aQ ?c3(K|] \}}}| ywr[r~rs rrz5TickLabels._get_ticklabels_offsets..!<1a!!.rrc3.K|] \}}}||z ywr[r~rs rrz5TickLabels._get_ticklabels_offsets..rrc3(K|] \}}}| ywr[r~rs rrz5TickLabels._get_ticklabels_offsets..rr)!get_texts_widths_heights_descentsget_vaget_hamax) rrurwhd_listrrrr max_ascent max_descents r_get_ticklabels_offsetsz"TickLabels._get_ticklabels_offsetss99(C  B f $0x00CV|F#v ExHB#v A '0x00CW}:#v 9xH6#v 5 (0x00CX~.#v -xH*#v )z! ?h ?? !!<8!<<  ;. #v  %0x00CU{#v xH#v z! ?h ?? !!<8!<<  ;. #v r)rr)rr)rrrrirr`c|js|j|_y|j||j\}}|j|j |j z}||z|_|jD]j\\}}}}|js||_ |j||j||j|tj||l||z|_yr[)rarrrrrirr_locs_angles_labelsstriprset_xset_yset_textrr|) rrur total_widthrxyals rr|zTickLabels.draw s!"&"4"4D  55h6:6J6JL;  8#<#F 1!@ !@ J  V $ii""".>> ?!@ . . DI DI#- "6" n- %'!$&! /rc|jj||jj|||_|dvr#|j d|j dy|j d|j dy)a Adjust the direction, text angle, and text alignment of tick labels and axis labels following the Matplotlib convention for the rectangle axes. The *axis_direction* must be one of [left, right, bottom, top]. ===================== ========== ========= ========== ========== Property left bottom right top ===================== ========== ========= ========== ========== ticklabel direction "-" "+" "+" "-" axislabel direction "-" "+" "+" "-" ticklabel angle 90 0 -90 180 ticklabel va center baseline center baseline ticklabel ha right center right center axislabel angle 180 0 0 180 axislabel va center top center bottom axislabel ha right center right center ===================== ========== ========= ========== ========== Note that the direction "+" and "-" are relative to the direction of the increasing coordinate. Also, the text angles are actually relative to (90 + angle of the direction to the ticklabel), which gives 0 for bottom axis. Parameters ---------- axis_direction : {"left", "bottom", "right", "top"} )rr-+N)major_ticklabelsrrrset_ticklabel_directionset_axislabel_direction)rrs rrzAxisArtist.set_axis_directionsr< 00@ %%n5- _ ,  ( ( -  ( ( -  ( ( -  ( ( -rcBtjddd||_y)z Adjust the direction of the tick labels. Note that the *tick_direction*\s '+' and '-' are relative to the direction of the increasing coordinate. Parameters ---------- tick_direction : {"+", "-"} rr`rHrG)tick_directionN)rrrB)rrNs rrJz"AxisArtist.set_ticklabel_directions!%)$6$6# ~%?!rc|jdzdz|_|jj|jjy)Nr`h)rBrIrminor_ticklabelsrs rinvert_ticklabel_directionz%AxisArtist.invert_ticklabel_directions>%)%>%>%D$K! 335 335rcBtjddd||_y)a Adjust the direction of the axis label. Note that the *label_direction*\s '+' and '-' are relative to the direction of the increasing coordinate. Parameters ---------- label_direction : {"+", "-"} rr`rM)rN)rrrCrs rrKz"AxisArtist.set_axislabel_directions"%)$6$6# %A!rcH|jj|jzSr[)rn transAxesr:rs rrgzAxisArtist.get_transformsyy""T%:%:::rc|jS)z5 Return axis artist helper instance. )r8rs r get_helperzAxisArtist.get_helpers'''rc |tjSt|tjr||_nt|fi||_|j y)a Set the axisline style. The new style is completely defined by the passed attributes. Existing style attributes are forgotten. Parameters ---------- axisline_style : str or None The line style, e.g. '->', optionally followed by a comma-separated list of attributes. Alternatively, the attributes can be provided as keywords. If *None* this returns a string containing the available styles. Examples -------- The following two commands are equal: >>> set_axisline_style("->,size=1.5") >>> set_axisline_style("->", size=1.5) N)r pprint_styles isinstance_Baser=r>)raxisline_styler7s rset_axisline_stylezAxisArtist.set_axisline_stylesM.  ! ..0 0 nm&9&9 :#1D #0#J6#JD  rc|jS)z"Return the current axisline style.)r=rs rget_axisline_stylezAxisArtist.get_axisline_style@s###rc |jj|j|jz}|j }|t |jj |jtjddtjdtjdtjd||_ y||||_ y) zY Initialize the *line* artist that is responsible to draw the axis line. Nzaxes.edgecolorFzaxes.linewidthzlines.solid_capstylezlines.solid_joinstyle)r+fill linewidthcapstyle joinstyle transform)re) r8get_line_transformrnr:r_rget_linemplrcParamsline)rtranr\s rr>zAxisArtist._init_lineDs((;;DIIF''(002  !!((11$))<ll#34,,'78&<=,,'>? DI'tt##ELL'+c1   " "C#4 5 & - -sK.G H  I :::rc| |jdj}|jd}|jj rV|jj r<|jj |z}||j_||j_n"d|j_d|j_|jj|j\}}|j|\}}|jj||jj||j|\}}|j j||jj|y)NTrr^r)rrrir|rarSr/rIrrQr8get_tick_iteratorsrnrr]r r})rrudpi_cor ticklabel_padmajortick_iterminortick_itertick_loc_angleticklabel_loc_angle_labels r _update_tickszAxisArtist._update_tickssM  D1??AH++B/    ' ' )d.>.>.K.K.M ,,66@M2?D ! ! /2?D ! ! /23D ! ! /23D ! ! /  $ $ 7 7 B '    / 21 ((8 445NO    / 21 ((8 445NOrc|j||jj||jj||jj||j j||jj s|j j r|j|yyr[)rr|r|rIr}rQra_draw_offsetTextrps r _draw_tickszAxisArtist._draw_tickss 8$ h' ""8, h' ""8,  ! ! - - /((446  ! !( +7r)rrrr)rrrr)rrrr)rrrrrc &|j|\}}}}tjd||fdddtjd|||_|j j t|jj|j y)Nz axes fractionrz offset pointsz xtick.color)xyxycoordsxytext textcoordsr+horizontalalignmentverticalalignment) _offsetText_posr Annotationrhri offsetTextrr rn_set_artist_props)r directionrrrrs rr@zAxisArtist._init_offsetTexts|++I6 1b"** 1vo,,}- "b   %%&7&9: ##DOO4rc|jj|jjjj |jj |jj|jj|jjzdz}d|f|j_ y)Nr) rrr)r formatter get_offsetset_sizerIrorxyann)rrEs r_update_offsetTextzAxisArtist._update_offsetTexts   !:!:!E!E!GH   !6!6!?!?!AB''//1))2245"#F rcZ|j|jj|yr[)rrr|rps rrzAxisArtist._draw_offsetTexts  ! X&rc |jj|j|jz}t dddd|j dt jdt jd|j||j |_ |jj|jjd |j d d }|jj|y) Nrrr labelsizezaxes.labelsizezaxes.labelweight)r+rw fontweightr)rerFrlabelpadr)r8get_axislabel_transformrnr:rr{rhrir)rr set_figurerr)rr7rrs rrAzAxisArtist._init_labels&&>>tyyI%%& q/ZZ S\\:J-KL||$67//   dii222>?::j!, 8$rc|jjsy|j|jk7r|jjr|jj r4|j jr1|jj s|jj}n7d}n4t|jj|jj}||j_ |jj|j\}}|y|dz }|\}}||jz|j_|jj#||y)Nrr)rr)rrarBrCr|rSr}r/rrIrrQrr8get_axislabel_pos_anglernrset)rru axislabel_padrrrrrs r _update_labelzAxisArtist._update_labels&zz%%'   $ $(A(A A!!--/))668$$002 ,,99; $ 0 0 : : !  5 5 D D $ 5 5 D DFM$1    $ $ < rqr?rrrrrr@rrrArrrrmartistallow_rasterizationr|rr%r&s@rr2r2s F $$__  (*0\&.P ?6 A;( B$=(! # J;,P:, 9!9"88:O 5,'% !:"2    '! '%+rr2)*r}operatorrnumpyrl matplotlibrhrrmatplotlib.artistartistrmatplotlib.colorscolorsr>matplotlib.texttextrmatplotlib.collectionsrmatplotlib.linesrmatplotlib.patchesrmatplotlib.pathr matplotlib.transformsr r r r r\rrr(TextrrrrArtistr2r~rrrsCR""##1#( ::* I I]OV]@E EP@@F}}@6.6rM+M+r