rL io.ddlZddlZddlmZmZmZddlmZ ddl m Z m Z ddl mZddlmZGdde ZdZej&j)e y) N)_api _docstring transforms) _AxesBase_TransformedBoundsLocator)Axis) TransformceZdZdZdfd ZdZddZdfd Zeje jddddZ d Z fd Z d Zd Zd ZdZxZS) SecondaryAxisz4 General class to hold a Secondary_X/Yaxis. c tjddg|||_||_||_d|_|jj d}|jdk(r7t | |gdfi||j|_ ddg|_ d d g|_ n6t | |gd fi||j|_ d d g|_ ddg|_ d |_|j|||j!||jdk(r |jn |j}|j#t%j&|j)d |j*|jj-d|j*|jj-d|j.dkr|jd d d|_ |j1|jdy )z See `.secondary_xaxis` and `.secondary_yaxis` for the doc string. While there is no need for this to be private, it should really be called by those higher level functions. xy) orientationF)root)r?-C6?topbottomleftright)rrrrNnoneTg?r)r check_in_list _functions_parent _orientation _ticks_set get_figuresuper__init__xaxis_axis _locstrings _otherstringsyaxis _parentscale set_location set_functionsset_major_locatormticker NullLocatorset_ticks_positionspines set_visible_pos set_alignment) selfparentrlocation functions transformkwargsfig otheraxis __class__s e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/axes/_secondary_axes.pyr!zSecondaryAxis.__init__s C:;?# 'll%%5%1    # G S"4 ? ?DJ %x0D "('!2D  G S"4 ? ?DJ '0D "'!2D   (I. 9%#'"3"3s":DJJ ##G$7$7$9:$$V, D&&'33E: D$$%11$7 99s?#//"5D  4++A./ctj|j|||jdk(r|jddd|_|j|jdj d|j|jdj d|j j ||j j|y)a< Set if axes spine and labels are drawn at top or bottom (or left/right) of the Axes. Parameters ---------- align : {'top', 'bottom', 'left', 'right'} Either 'top' or 'bottom' for orientation='x' or 'left' or 'right' for orientation='y' axis. )alignrNrrTF)rrr$r.r/r#r-set_label_position)r2r>s r;r1zSecondaryAxis.set_alignment<s 4++59 D$$Q' '#//"5D  D$$Q'(44T: D$$Q'(44U; %%e, %%e,r<ctjtjdf|t |t r/tj |j||dvrdnd|_nPt |tjr||_n.td|jdd |jd d |||_ |jd k(r=d|jdd g}|gtj|jj |}n<|jdd d g}|*tj||jj }||jj }|j#t%||y)a  Set the vertical or horizontal location of the axes in parent-normalized coordinates. Parameters ---------- location : {'top', 'bottom', 'left', 'right'} or float The position to put the secondary axis. Strings can be 'top' or 'bottom' for orientation='x' and 'right' or 'left' for orientation='y'. A float indicates the relative position on the parent Axes to put the new Axes, 0.0 being the bottom (or left) and 1.0 being the top (or right). transform : `.Transform`, optional Transform for the location to use. Defaults to the parent's ``transAxes``, so locations are normally relative to the parent axes. .. versionadded:: 3.9 N)r6)r4)rrrgzlocation must be rz, rz, or a float, not r g|=)rcheck_isinstancerr isinstancestrrr$r0numbersReal ValueError_locrblended_transform_factoryr transAxesset_axes_locatorr)r2r4r6boundss r;r(zSecondaryAxis.set_locationOsc, z33T:iP h $   t//( C&*::DI ',, / DI#D$4$4Q$7#:"##A&));H<IJ J    #B.F $&@@LL**I7 iiE1-F$&@@t||557    ..I 7 JKr<cD|jt| |yN) _set_limsr apply_aspect)r2positionr:s r;rOzSecondaryAxis.apply_aspects  X&r<F)minorc b|jj||fd|i|}d|_d|_|S)NrQT)r# set_ticksstaler)r2tickslabelsrQr7rets r;rSzSecondaryAxis.set_tickss7"djj""5&HHH  r<c*ttr2tdk(r$tdrtdr|_n@tt rj fdf|_n ddf|_n td|jy) a& Set how the secondary axis converts limits from the parent Axes. Parameters ---------- functions : 2-tuple of func, or `Transform` with an inverse. Transform between the parent axis values and the secondary axis values. If supplied as a 2-tuple of functions, the first function is the forward transform function and the second is the inverse transform. If a transform is supplied, then the transform must have an inverse. rrcBjj|SrM)invertedr6)r r5s r;z-SecondaryAxis.set_functions..s9--/99!<r<Nc|SrMr s r;r\z-SecondaryAxis.set_functions..sr<c|SrMr^r_s r;r\z-SecondaryAxis.set_functions..sar<zfunctions argument of secondary Axes must be a two-tuple of callable functions with the first function being the transform and the second being the inverse) rBtuplelencallablerr r6rF _set_scale)r2r5s `r;r)zSecondaryAxis.set_functionss$ y% (S^q-@1&8IaL+A(DO  9 -$$<DO *K8DO@A A r<cd|j|jt| |y)z Draw the secondary Axes. Consults the parent Axes for its limits and converts them using the converter specified by `~.axes._secondary_axes.set_functions` (or *functions* parameter when Axes initialized.) N)rNrdr draw)r2rendererr:s r;rfzSecondaryAxis.draws%    Xr<c|jdk(r1|jjj}|j}n0|jj j}|j }||jk(ry|jr|jj}||dk(rdnd|jddd|jr.|jjtj||_y)z3 Check if parent has set its scale r Nlog functionlogfunctionr)r5)rrr" get_scale set_xscaler& set_yscaler'rr# get_ticklocsrr*r+ FixedLocator)r2pscale set_scalerUs r;rdzSecondaryAxis._set_scales    #\\''113FI\\''113FI T&& &  ??JJ++-E 6U?-  OODbD1 3 ?? JJ ( ()=)=e)D E#r<cb|jdk(r'|jj}|j}n&|jj }|j }|d|dk}|j dtj|}|d|dk}||k7r|ddd}||y)z Set the limits based on parent limits and the convert method between the parent and this secondary Axes. r rrNr) rrget_xlimset_xlimget_ylimset_ylimrnparray)r2limsset_limorderneworders r;rNzSecondaryAxis._set_limss    #<<((*DmmG<<((*DmmGQ$q'!!tq!"((4.17T!W$ u ":D r<c.tjdy)zj Secondary Axes cannot set the aspect ratio, so calling this just sets a warning. z)Secondary Axes can't set the aspect ratioN)r warn_external)r2argsr7s r; set_aspectzSecondaryAxis.set_aspects FGr<c|j|j}|j||jj D]"}|j |us|j |$|jj |y)z Change the color of the secondary Axes and all decorators. Parameters ---------- color : :mpltype:`color` )colorsN) _axis_maprset_tick_paramsr.valuesaxis set_colorlabel)r2colorrspines r;rzSecondaryAxis.set_colorsq~~d//0 E*[['') 'EzzT!& ' U#r<rM)__name__ __module__ __qualname____doc__r!r1r(rOrcopyrrSr)rfrdrNrr __classcell__)r:s@r;r r si)0V-&>L@' Z__T^^$U% #J #:&H $r<r a Warnings -------- This method is experimental as of 3.1, and the API may change. Parameters ---------- location : {'top', 'bottom', 'left', 'right'} or float The position to put the secondary axis. Strings can be 'top' or 'bottom' for orientation='x' and 'right' or 'left' for orientation='y'. A float indicates the relative position on the parent Axes to put the new Axes, 0.0 being the bottom (or left) and 1.0 being the top (or right). functions : 2-tuple of func, or Transform with an inverse If a 2-tuple of functions, the user specifies the transform function and its inverse. i.e. ``functions=(lambda x: 2 / x, lambda x: 2 / x)`` would be an reciprocal transform with a factor of 2. Both functions must accept numpy arrays as input. The user can also directly supply a subclass of `.transforms.Transform` so long as it has an inverse. See :doc:`/gallery/subplots_axes_and_figures/secondary_axis` for examples of making these conversions. transform : `.Transform`, optional If specified, *location* will be placed relative to this transform (in the direction of the axis) rather than the parent's axis. i.e. a secondary x-axis will use the provided y transform and the x transform of the parent. .. versionadded:: 3.9 Returns ------- ax : axes._secondary_axes.SecondaryAxis Other Parameters ---------------- **kwargs : `~matplotlib.axes.Axes` properties. Other miscellaneous Axes parameters. )_secax_docstring)rDnumpyrx matplotlibrrrmatplotlib.tickertickerr+matplotlib.axes._baserrmatplotlib.axisrmatplotlib.transformsr r rinterpdregisterr^r<r;rsO33#F +F$IF$R,Z -=>r<