rL iu|dZddlZddlZddlZddlZddlmZddlZddlZ ddl Z ddl m Z m Z ddl mZej eZdZGddZGd d ZGd d eZGd deZGddeZGddeZGddeZGddej,ZGddeZGddeZGddeZGddeZGdd eZ Gd!d"e Z!Gd#d$eZ"Gd%d&eZ#Gd'd(eZ$Gd)d*eZ%Gd+d,e%Z&Gd-d.e%Z'Gd/d0e%Z(Gd1d2e%Z)Gd3d4e%Z*dNd5Z+Gd6d7Z,Gd8d9e%Z-d:dd;d<Z.d=Z/d>Z0d?Z1d@Z2dAZ3GdBdCe%Z4GdDdEe%Z5GdFdGe%Z6GdHdIe-Z7GdJdKe-Z8GdLdMe%Z9y)Oa Tick locating and formatting ============================ This module contains classes for configuring tick locating and formatting. Generic tick locators and formatters are provided, as well as domain specific custom ones. Although the locators know nothing about major or minor ticks, they are used by the Axis class to support major and minor tick locating and formatting. .. _tick_locating: .. _locators: Tick locating ------------- The Locator class is the base class for all tick locators. The locators handle autoscaling of the view limits based on the data limits, and the choosing of tick locations. A useful semi-automatic tick locator is `MultipleLocator`. It is initialized with a base, e.g., 10, and it picks axis limits and ticks that are multiples of that base. The Locator subclasses defined here are: ======================= ======================================================= `AutoLocator` `MaxNLocator` with simple defaults. This is the default tick locator for most plotting. `MaxNLocator` Finds up to a max number of intervals with ticks at nice locations. `LinearLocator` Space ticks evenly from min to max. `LogLocator` Space ticks logarithmically from min to max. `MultipleLocator` Ticks and range are a multiple of base; either integer or float. `FixedLocator` Tick locations are fixed. `IndexLocator` Locator for index plots (e.g., where ``x = range(len(y))``). `NullLocator` No ticks. `SymmetricalLogLocator` Locator for use with the symlog norm; works like `LogLocator` for the part outside of the threshold and adds 0 if inside the limits. `AsinhLocator` Locator for use with the asinh norm, attempting to space ticks approximately uniformly. `LogitLocator` Locator for logit scaling. `AutoMinorLocator` Locator for minor ticks when the axis is linear and the major ticks are uniformly spaced. Subdivides the major tick interval into a specified number of minor intervals, defaulting to 4 or 5 depending on the major interval. ======================= ======================================================= There are a number of locators specialized for date locations - see the :mod:`.dates` module. You can define your own locator by deriving from Locator. You must override the ``__call__`` method, which returns a sequence of locations, and you will probably want to override the autoscale method to set the view limits from the data limits. If you want to override the default locator, use one of the above or a custom locator and pass it to the x- or y-axis instance. The relevant methods are:: ax.xaxis.set_major_locator(xmajor_locator) ax.xaxis.set_minor_locator(xminor_locator) ax.yaxis.set_major_locator(ymajor_locator) ax.yaxis.set_minor_locator(yminor_locator) The default minor locator is `NullLocator`, i.e., no minor ticks on by default. .. note:: `Locator` instances should not be used with more than one `~matplotlib.axis.Axis` or `~matplotlib.axes.Axes`. So instead of:: locator = MultipleLocator(5) ax.xaxis.set_major_locator(locator) ax2.xaxis.set_major_locator(locator) do the following instead:: ax.xaxis.set_major_locator(MultipleLocator(5)) ax2.xaxis.set_major_locator(MultipleLocator(5)) .. _formatters: Tick formatting --------------- Tick formatting is controlled by classes derived from Formatter. The formatter operates on a single tick value and returns a string to the axis. ========================= ===================================================== `NullFormatter` No labels on the ticks. `FixedFormatter` Set the strings manually for the labels. `FuncFormatter` User defined function sets the labels. `StrMethodFormatter` Use string `format` method. `FormatStrFormatter` Use an old-style sprintf format string. `ScalarFormatter` Default formatter for scalars: autopick the format string. `LogFormatter` Formatter for log axes. `LogFormatterExponent` Format values for log axis using ``exponent = log_base(value)``. `LogFormatterMathtext` Format values for log axis using ``exponent = log_base(value)`` using Math text. `LogFormatterSciNotation` Format values for log axis using scientific notation. `LogitFormatter` Probability formatter. `EngFormatter` Format labels in engineering notation. `PercentFormatter` Format labels as a percentage. ========================= ===================================================== You can derive your own formatter from the Formatter base class by simply overriding the ``__call__`` method. The formatter class has access to the axis view and data limits. To control the major and minor tick label formats, use one of the following methods:: ax.xaxis.set_major_formatter(xmajor_formatter) ax.xaxis.set_minor_formatter(xminor_formatter) ax.yaxis.set_major_formatter(ymajor_formatter) ax.yaxis.set_minor_formatter(yminor_formatter) In addition to a `.Formatter` instance, `~.Axis.set_major_formatter` and `~.Axis.set_minor_formatter` also accept a ``str`` or function. ``str`` input will be internally replaced with an autogenerated `.StrMethodFormatter` with the input ``str``. For function input, a `.FuncFormatter` with the input function will be generated and used. See :doc:`/gallery/ticks/major_minor_demo` for an example of setting major and minor ticks. See the :mod:`matplotlib.dates` module for more information and examples of using date locators and formatters. N)Integral)_apicbook) transforms) TickHelper FormatterFixedFormatter NullFormatter FuncFormatterFormatStrFormatterStrMethodFormatterScalarFormatter LogFormatterLogFormatterExponentLogFormatterMathtextLogFormatterSciNotationLogitFormatter EngFormatterPercentFormatterLocator IndexLocator FixedLocator NullLocator LinearLocator LogLocator AutoLocatorMultipleLocator MaxNLocatorAutoMinorLocatorSymmetricalLogLocator AsinhLocator LogitLocatorc<eZdZdZd dZdZdZdZdZdZdZ y ) _DummyAxisdummyc.d|_d|_||_y)N)r)_data_interval_view_interval_minpos)selfminposs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/ticker.py__init__z_DummyAxis.__init__s$$ c|jSNr)r+s r-get_view_intervalz_DummyAxis.get_view_interval"""r/c||f|_yr1r2r+vminvmaxs r-set_view_intervalz_DummyAxis.set_view_interval#Tlr/c|jSr1)r*r3s r- get_minposz_DummyAxis.get_minposs ||r/c|jSr1r(r3s r-get_data_intervalz_DummyAxis.get_data_intervalr5r/c||f|_yr1r?r7s r-set_data_intervalz_DummyAxis.set_data_intervalr;r/cy)N r3s r-get_tick_spacez_DummyAxis.get_tick_spacesr/Nr) __name__ __module__ __qualname__r.r4r:r=r@rBrFrEr/r-r$r$s*H #+#+r/r$ceZdZdZdZdZy)rNc||_yr1)axis)r+rMs r-set_axiszTickHelper.set_axiss  r/c >|jtdi||_yy)NrE)rMr$r+kwargss r-create_dummy_axiszTickHelper.create_dummy_axiss 99 ",V,DI r/)rHrIrJrMrNrRrEr/r-rrs D-r/rcPeZdZdZgZd dZdZdZdZdZ dZ e d Z d Z y) rz= Create a string based on a tick value and location. Nctd)z Return the format for tick value *x* at position pos. ``pos=None`` indicates an unspecified location. Derived must overrideNotImplementedErrorr+xposs r-__call__zFormatter.__call__s ""9::r/cz|j|t|Dcgc]\}}|||c}}Scc}}w)z1Return the tick labels for all the ticks at once.)set_locs enumerate)r+valuesivalues r- format_tickszFormatter.format_tickss1 f/8/@A81eUAAAAs7c$|j|S)zk Return the full string representation of the value with the position unspecified. )r[r+ras r- format_datazFormatter.format_datas }}U##r/c$|j|S)z| Return a short string version of the tick value. Defaults to the position-independent long value. rerds r-format_data_shortzFormatter.format_data_shorts &&r/cyNrEr3s r- get_offsetzFormatter.get_offsetsr/c||_y)z Set the locations of the ticks. This method is called before computing the tick labels because some formatters need to know all tick locations to do so. Nlocsr+ros r-r]zFormatter.set_locss  r/cPtjdr|jddS|S)a  Some classes may want to replace a hyphen for minus with the proper Unicode symbol (U+2212) for typographical correctness. This is a helper method to perform such a replacement when it is enabled via :rc:`axes.unicode_minus`. zaxes.unicode_minus-u−)mplrcParamsreplace)ss r- fix_minuszFormatter.fix_minuss/<< 45 #/0  r/cy)z6Subclasses may want to override this to set a locator.NrE)r+locators r- _set_locatorzFormatter._set_locators r/r1)rHrIrJ__doc__ror[rbrerhrlr] staticmethodrwrzrEr/r-rrsF D;B $'   r/rceZdZdZddZy)r zAlways return the empty string.NcyrjrErXs r-r[zNullFormatter.__call__ sr/r1)rHrIrJr{r[rEr/r-r r s )r/r c*eZdZdZdZddZdZdZy)r z Return fixed strings for tick labels based only on position, not value. .. note:: `.FixedFormatter` should only be used together with `.FixedLocator`. Otherwise, the labels may end up in unexpected positions. c ||_d|_y)z?Set the sequence *seq* of strings that will be used for labels.rkN)seq offset_string)r+rs r-r.zFixedFormatter.__init__sr/NcV||t|jk\ry|j|S)a Return the label that matches the position, regardless of the value. For positions ``pos < len(seq)``, return ``seq[i]`` regardless of *x*. Otherwise return empty string. ``seq`` is the sequence of strings that this object was initialized with. rk)lenrrXs r-r[zFixedFormatter.__call__s) ;#TXX.88C= r/c|jSr1rr3s r-rlzFixedFormatter.get_offset*!!!r/c||_yr1rr+ofss r-set_offset_stringz FixedFormatter.set_offset_string-  r/r1rHrIrJr{r.r[rlrrEr/r-r r s !"!r/r c*eZdZdZdZddZdZdZy)r z Use a user-defined function for formatting. The function should take in two inputs (a tick value ``x`` and a position ``pos``), and return a string containing the corresponding tick label. c ||_d|_yrj)funcr)r+rs r-r.zFuncFormatter.__init__:s r/Nc&|j||S)zq Return the value of the user defined function. *x* and *pos* are passed through as-is. )rrXs r-r[zFuncFormatter.__call__>s yyC  r/c|jSr1rr3s r-rlzFuncFormatter.get_offsetFrr/c||_yr1rrs r-rzFuncFormatter.set_offset_stringIrr/r1rrEr/r-r r 1s !"!r/r ceZdZdZdZddZy)r a Use an old-style ('%' operator) format string to format the tick. The format string should have a single variable format (%) in it. It will be applied to the value (not the position) of the tick. Negative numeric values (e.g., -1) will use a dash, not a Unicode minus; use mathtext to get a Unicode minus by wrapping the format specifier with $ (e.g. "$%g$"). c||_yr1fmtr+rs r-r.zFormatStrFormatter.__init__Y r/Nc |j|zS)zw Return the formatted label string. Only the value *x* is formatted. The position is ignored. rrXs r-r[zFormatStrFormatter.__call__\s xx!|r/r1rHrIrJr{r.r[rEr/r-r r Ms r/r c"eZdZdZfdZxZS)_UnicodeMinusFormata. A specialized string formatter so that `.StrMethodFormatter` respects :rc:`axes.unicode_minus`. This implementation relies on the fact that the format string is only ever called with kwargs *x* and *pos*, so it blindly replaces dashes by unicode minuses without further checking. cJtjt| ||Sr1)rrwsuper format_field)r+ra format_spec __class__s r-rz _UnicodeMinusFormat.format_fieldms ""57#7{#KLLr/)rHrIrJr{r __classcell__rs@r-rresMMr/rceZdZdZdZddZy)r a Use a new-style format string (as used by `str.format`) to format the tick. The field used for the tick value must be labeled *x* and the field used for the tick position must be labeled *pos*. The formatter will respect :rc:`axes.unicode_minus` when formatting negative numeric values. It is typically unnecessary to explicitly construct `.StrMethodFormatter` objects, as `~.Axis.set_major_formatter` directly accepts the format string itself. c||_yr1rrs r-r.zStrMethodFormatter.__init__rr/NcNtj|j||S)z Return the formatted label string. *x* and *pos* are passed to `str.format` as keyword arguments with those exact names. )rYrZ)rformatrrXs r-r[zStrMethodFormatter.__call__s##$++DHHs+CCr/r1rrEr/r-r r qs Dr/r ceZdZdZddddZdZdZeeeZdZ d Z ee e Z d Z d Z ee e Zd Zd ZdZeeeZddZdZdZdZdZdZdZdZdZdZy)ra@ Format tick values as a number. Parameters ---------- useOffset : bool or float, default: :rc:`axes.formatter.useoffset` Whether to use offset notation. See `.set_useOffset`. useMathText : bool, default: :rc:`axes.formatter.use_mathtext` Whether to use fancy math formatting. See `.set_useMathText`. useLocale : bool, default: :rc:`axes.formatter.use_locale`. Whether to use locale settings for decimal sign and positive sign. See `.set_useLocale`. usetex : bool, default: :rc:`text.usetex` To enable/disable the use of TeX's math mode for rendering the numbers in the formatter. .. versionadded:: 3.10 Notes ----- In addition to the parameters above, the formatting of scientific vs. floating point representation can be configured via `.set_scientific` and `.set_powerlimits`). **Offset notation and scientific notation** Offset notation and scientific notation look quite similar at first sight. Both split some information from the formatted tick values and display it at the end of the axis. - The scientific notation splits up the order of magnitude, i.e. a multiplicative scaling factor, e.g. ``1e6``. - The offset notation separates an additive constant, e.g. ``+1e6``. The offset notation label is always prefixed with a ``+`` or ``-`` sign and is thus distinguishable from the order of magnitude label. The following plot with x limits ``1_000_000`` to ``1_000_010`` illustrates the different formatting. Note the labels at the right edge of the x axis. .. plot:: lim = (1_000_000, 1_000_010) fig, (ax1, ax2, ax3) = plt.subplots(3, 1, gridspec_kw={'hspace': 2}) ax1.set(title='offset notation', xlim=lim) ax2.set(title='scientific notation', xlim=lim) ax2.xaxis.get_major_formatter().set_useOffset(False) ax3.set(title='floating-point notation', xlim=lim) ax3.xaxis.get_major_formatter().set_useOffset(False) ax3.xaxis.get_major_formatter().set_scientific(False) N)usetexc@|tjd}tjd|_|j||j ||j |d|_d|_d|_tjd|_ |j|y)Nzaxes.formatter.useoffsetzaxes.formatter.offset_thresholdrrkTzaxes.formatter.limits) rsrt_offset_threshold set_useOffset set_usetexset_useMathTextorderOfMagnituder _scientific _powerlimits set_useLocale)r+ useOffset useMathText useLocalers r-r.zScalarFormatter.__init__s   %?@I LL: ;  9%  [) ! LL)@A 9%r/c|jS)z8Return whether TeX's math mode is enabled for rendering.)_usetexr3s r- get_usetexzScalarFormatter.get_usetexs ||r/c:tj|d|_y)zJSet whether to use TeX's math mode for rendering numbers in the formatter. text.usetexN)rs _val_or_rcrr+vals r-rzScalarFormatter.set_usetexs~~c=9 r/)fgetfsetc|jS)a$ Return whether automatic mode for offset notation is active. This returns True if ``set_useOffset(True)``; it returns False if an explicit offset was set, e.g. ``set_useOffset(1000)``. See Also -------- ScalarFormatter.set_useOffset ) _useOffsetr3s r- get_useOffsetzScalarFormatter.get_useOffsetsr/cF|dvrd|_||_yd|_||_y)a Set whether to use offset notation. When formatting a set numbers whose value is large compared to their range, the formatter can separate an additive constant. This can shorten the formatted numbers so that they are less likely to overlap when drawn on an axis. Parameters ---------- val : bool or float - If False, do not use offset notation. - If True (=automatic mode), use offset notation if it can make the residual numbers significantly shorter. The exact behavior is controlled by :rc:`axes.formatter.offset_threshold`. - If a number, force an offset of the given value. Examples -------- With active offset notation, the values ``100_000, 100_002, 100_004, 100_006, 100_008`` will be formatted as ``0, 2, 4, 6, 8`` plus an offset ``+1e5``, which is written to the edge of the axis. )TFrFN)offsetrrs r-rzScalarFormatter.set_useOffsets(6 - DK!DO#DODKr/c|jS)z Return whether locale settings are used for formatting. See Also -------- ScalarFormatter.set_useLocale ) _useLocaler3s r- get_useLocalezScalarFormatter.get_useLocalesr/cH|tjd|_y||_y)z Set whether to use locale settings for decimal sign and positive sign. Parameters ---------- val : bool or None *None* resets to :rc:`axes.formatter.use_locale`. Nzaxes.formatter.use_locale)rsrtrrs r-rzScalarFormatter.set_useLocales! ;!ll+FGDO!DOr/c|j|jrU|jr-djfd|j dDSt j |fdS|zS)zX Format *arg* with *fmt*, applying Unicode minus and locale if desired. ,c3nK|],}tj|fdjdd.yw)Trz{,}N)locale format_stringru).0partargs r- zAScalarFormatter._format_maybe_minus_and_locale../s86"!..tcVTBJJ3PUV6s25T)rwr _useMathTextjoinsplitrr)r+rrs `r-_format_maybe_minus_and_localez.ScalarFormatter._format_maybe_minus_and_locale(s~~ ??:>9J9J6&)iin66  **3=   3Y  r/c|jS)z Return whether to use fancy math formatting. See Also -------- ScalarFormatter.set_useMathText )rr3s r-get_useMathTextzScalarFormatter.get_useMathText5s   r/cl|tjd|_|jdurs ddlm}|j |j tjdd}|ttjd k(rtjd yyy||_y#t$rd}YNwxYw) a Set whether to use fancy math formatting. If active, scientific notation is formatted as :math:`1.2 \times 10^3`. Parameters ---------- val : bool or None *None* resets to :rc:`axes.formatter.use_mathtext`. Nzaxes.formatter.use_mathtextFr) font_managerz font.family)family)fallback_to_defaultzfonts/ttf/cmr10.ttfzXcmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True) rsrtr matplotlibrfindfontFontProperties ValueErrorstrr_get_data_pathr warn_external)r+rrufonts r-rzScalarFormatter.set_useMathText?s ; # -J KD   E) !7(11$33#&<< #>4-2 2EC 4 45J KLL&&LM*$!$D "! E!s:B%% B32B3ct|jdk(ry||jz d|jzz }t |dkrd}|j |j |S)zI Return the format for tick value *x* at position *pos*. rrk$@:0yE>)rrorrabsrrr+rYrZxps r-r[zScalarFormatter.__call__bs[ tyy>Q dkk/cT-B-B&BCB2w~66t{{BG Gr/c$t||_y)z Turn scientific notation on or off. See Also -------- ScalarFormatter.set_powerlimits N)boolr)r+bs r-set_scientificzScalarFormatter.set_scientificns 7r/cDt|dk7r td||_y)a Set size thresholds for scientific notation. Parameters ---------- lims : (int, int) A tuple *(min_exp, max_exp)* containing the powers of 10 that determine the switchover threshold. For a number representable as :math:`a \times 10^\mathrm{exp}` with :math:`1 <= |a| < 10`, scientific notation will be used if ``exp <= min_exp`` or ``exp >= max_exp``. The default limits are controlled by :rc:`axes.formatter.limits`. In particular numbers with *exp* equal to the thresholds are written in scientific notation. Typically, *min_exp* will be negative and *max_exp* will be positive. For example, ``formatter.set_powerlimits((-3, 4))`` will provide the following formatting: :math:`1 \times 10^{-3}, 9.9 \times 10^{-3}, 0.01,` :math:`9999, 1 \times 10^4`. See Also -------- ScalarFormatter.set_scientific z%'lims' must be a sequence of length 2N)rrr)r+limss r-set_powerlimitszScalarFormatter.set_powerlimitsxs#< t9>DE E r/cH|tjjuryt|trd}n`t |j dddvr|j jdk(ri|j jj}|j}|j|df}|j|ddgddggzdddf}nh|j jj}|j}|jd|f}|j|ddgddggzdddf}t||z j}n%|j j\}} | |z d z }d t!j"||d }|j%||S) Nrk%drH)xaxisyaxisrrr'@z%-#.g)npmamasked isinstancergetattrrMrHaxesget_xaxis_transforminverted transformget_yaxis_transformrmaxr4r _g_sig_digitsr) r+raraxis_trf axis_inv_trf screen_xyneighbor_valuesdeltaars r-rhz!ScalarFormatter.format_data_shorts BEELL  eX &Ctyy*b15GG99%%0#yy~~AACH#+#4#4#6L ( 2 2E1: >I&2&<&<!b!Wr1g$66'8891'>O $yy~~AACH#+#4#4#6L ( 2 2Au: >I&2&<&<!aWq"g$66'8891'>OOe3488:yy2241Q# ,,UE:;1=C223>>r/cVtjtjt|}t |d|zz d}|j |dzdk(rdnd|}|dk(r|S|j d|}|j s |jrd|z}|dk(r|S|d|S|d|S) N r'rrz%1.10gz10^{%s}z \times e)mathfloorlog10rroundrrr)r+rarrv significandexponents r-rezScalarFormatter.format_datas JJtzz#e*- . %"a%- $99EQJDHa1 6 66tQ?     8+H !QH >(M(< >"]!H:. .r/c(t|jdk(ry|js |jrd}d}|jr/|j |j}|jdkDrd|z}|jrF|j s |j r|j d|jz}nd|jz}|j s |j r|dk7rd|z}d|d|d }ndj||f}|j|Sy) z: Return scientific notation, plus offset. rrk+r z1e%dz\times\mathdefault{%s}$z \mathdefault{z}$) rrorrrerrrrwr+ offsetStr sciNotStrrvs r-rlzScalarFormatter.get_offsets tyy>Q   DKKII{{ ,,T[[9 ;;? #iI$$<<4#4#4 $ 0 0t7L7L1L MI &)>)> >I  DLL? 9I EI >)C@GGY 23>>!$ $r/c||_t|jdkDr=|jr|j|j |j yy)Nr)rorr_compute_offset_set_order_of_magnitude _set_formatrps r-r]zScalarFormatter.set_locssI tyy>A $$&  ( ( *     r/c |j}t|jj\}}t j |}|||k||kz}t |sd|_y|j|j}}||k(s|dcxkr |krd|_ynd|_yttt|tt|g\ tjd|}t jtj }dt! fdt#j$|dDz} z d|zz dkr,dt! fdt#j$|dDz}|j&dz } d|zzd| zk\r| d|zzzd|zz|_yd|_y)Nrr'c3DK|]}d|zzd|zzk7r|yw)r NrEroomabs_maxabs_mins r-rz2ScalarFormatter._compute_offset..s4Hs!R3Y.'R3Y2FFHs rr {Gz?c3JK|]}d|zzd|zzz dkDr|yw)r r'NrEr!s r-rz2ScalarFormatter._compute_offset.. s9O3%s2Wc 5IIAMOs #)rosortedrMr4rasarrayrrminrrfloatrcopysignceilrnext itertoolscountr) r+ror8r9lminlmaxsignoom_maxr"nr#r$s @@r-rzScalarFormatter._compute_offsetsyyDII779: dzz$TT\ddl344yDK XXZd 4<41,,DK -DK "3uT{#3St5E"FG}}Q% ''$**W-.$Hioogr&BHHH g s *d 2 dO)//'2*FOOOC  " "Q &!R3Y."a%7w")34rSy@  r/c|jsd|_y|jd|jdcxk(rdk7rnn|jd|_yt|jj \}}t j|j}|||k||kz}t j|}t|sd|_y|jr,tjtj||z }n@|j}|dk(rd}n(tjtj|}||jdkr||_y||jdk\r||_yd|_yNrr')rrrr'rMr4rr(rorrrrrrr)r+r8r9ror"rs r-rz'ScalarFormatter._set_order_of_magnitudesA$%D !    Q 4#4#4Q#7 <1 <$($5$5a$8D ! DII779: dzz$))$TT\ddl34vvd|4y$%D !  ;;**TZZt 45C((*CaxjjC1 $##A& &$'D ! D%%a( ($'D !$%D !r/cxt|jdkr)g|j|jj}n |j}t j ||j z d|jzz }t j|}|dk(r(t jt j|}|dk(rd}t|jdkr|dd}ttjtj|}tdd|z }dd|zz}|dk\rKt j|t j|| z j|kr|dz}nn|dk\rK|dz }d |d |_|j"s |j$rd |j z|_yy) Nrrrr'MbP?r )decimalsz%1.f$\mathdefault{%s}$)rrorMr4rr(rrptprrintrrrrrrr)r+_locsro loc_range loc_range_oomsigfigsthreshs r-rzScalarFormatter._set_format3st tyy>A @dii@$))"="="?@EIIE 5!DKK/3$:O:O3OOFF4L >rvvd|,I >I tyy>A 9DDJJtzz)'<=> a]*+m++lvvdRXXdW==>BBDvM1  l 1 G9A& <<4,,/$++=DK-r/)NNNr1)rHrIrJr{r.rrpropertyrrrrrrrrrrrr[rrrhrerlr]rrrrEr/r-rrs4l & &::J 7F  Dm-@I "m-@I  !$BoFK H# !D?8/ 6%N &D>r/rcReZdZdZ d dZdZdZd dZdZd dZ d Z d Z d Z y)ra Base class for formatting ticks on a log or symlog scale. It may be instantiated directly, or subclassed. Parameters ---------- base : float, default: 10. Base of the logarithm used in all calculations. labelOnlyBase : bool, default: False If True, label ticks only at integer powers of base. This is normally True for major ticks and False for minor ticks. minor_thresholds : (subset, all), default: (1, 0.4) If labelOnlyBase is False, these two numbers control the labeling of ticks that are not at integer powers of base; normally these are the minor ticks. The controlling parameter is the log of the axis data range. In the typical case where base is 10 it is the number of decades spanned by the axis, so we can call it 'numdec'. If ``numdec <= all``, all minor ticks will be labeled. If ``all < numdec <= subset``, then only a subset of minor ticks will be labeled, so as to avoid crowding. If ``numdec > subset`` then no minor ticks will be labeled. linthresh : None or float, default: None If a symmetric log scale is in use, its ``linthresh`` parameter must be supplied here. Notes ----- The `set_locs` method must be called to enable the subsetting logic controlled by the ``minor_thresholds`` parameter. In some cases such as the colorbar, there is no distinction between major and minor ticks; the tick locations might be set manually, or by a locator that puts ticks at integer powers of base and at intermediate locations. For this situation, disable the minor_thresholds logic by using ``minor_thresholds=(np.inf, np.inf)``, so that all ticks will be labeled. To disable labeling of minor ticks when 'labelOnlyBase' is False, use ``minor_thresholds=(0, 0)``. This is the default for the "classic" style. Examples -------- To label a subset of minor ticks when the view limits span up to 2 decades, and all of the ticks when zoomed in to 0.5 decades or less, use ``minor_thresholds=(2, 0.5)``. To label all minor ticks when the view limits span up to 1.5 decades, use ``minor_thresholds=(1.5, 1.5)``. Nc|j||j||tjdrd}nd}||_d|_||_y)N_internal.classic_moderr)r'g?)set_baseset_label_minorrsrtminor_thresholds _sublabels _linthresh)r+base labelOnlyBaserL linthreshs r-r.zLogFormatter.__init__sS d ]+  #||45#) #+ 0#r/c$t||_y)z Change the *base* for labeling. .. warning:: Should always match the base used for :class:`LogLocator` N)r*_base)r+rOs r-rJzLogFormatter.set_bases4[ r/c||_y)z Switch minor tick labeling on or off. Parameters ---------- labelOnlyBase : bool If True, label ticks only at integer powers of base. NrP)r+rPs r-rKzLogFormatter.set_label_minors +r/c|tj|jdrd|_y|j}|% |j j j}|j j\}}||kDr||}}||dkr dh|_y|j}|d}|| kr>t|| }|tj||z tj|z z }||kDrt||}|tj||z tj|z z }ndtj|tj|z }tj|tj|z }t||z }||jdkDr dh|_y||jdkDrJtj d|t#|dzdz} t%tj&| |_yt%tj(d|dz|_y#t$rYwxYw)z Use axis view limits to control which ticks are labeled. The *locs* parameter is ignored in the present algorithm. rNr'r)risinfrLrMrNrM get_transformrQAttributeErrorr4rSr)rlogrr geomspacer?setrarange) r+rorQr8r9rnumdecrhslhscs r-r]zLogFormatter.set_locss 88D))!, -"DO OO    II335?? YY002 d $;t$D   !cDO  JJ  Fyj $ +$((4#:.!<<i$ *$((4#:.!<<88D>DHHQK/D88D>DHHQK/D%F D))!, , cDO d++A. . Q3q619q=1A!"((1+.DO""))Aq1u"56DOU"  s$H.. H;:H;cPd|cxkrdkrnn|j|||z S|dS)Nr''z1.0e) _pprint_val)r+rYr8r9s r-_num_to_stringzLogFormatter._num_to_strings,34?U?t4$;/S1T(Sr/c|dk(ryt|}|j}tj|tj|z }t |}|r t |nt j|}t |||z z}|jr|sy|j||jvry|jj\}} tj|| d\}} |j||| } |j| S)N0rk皙?expander)rrSrrZ_is_close_to_intrrrrPrMrMr4 mtransforms nonsingularrerw) r+rYrZrfx is_x_decadercoeffr8r9rvs r-r[zLogFormatter.__call__s 8 F JJ XXa[488A; &&r* +59"aBM*+   k ?? &5+GYY002 d ,,T4$G d   4 .~~a  r/ctj|d5tj|j|cdddS#1swYyxYw)NFrU)r _setattr_cm strip_mathr[rds r-rezLogFormatter.format_datas>   t5 9 :##DMM%$89 : : :s $AAc(d|zjS)Nz%-12g)rstriprds r-rhzLogFormatter.format_data_short s%''))r/ct|dkr|t|k(rd|zS|dkrdn|dkrdn|dkrdn|d krd nd }||z}|jd }t|d k(r@|dj dj d}t|d}|r d||fz}|S|}|S|j dj d}|S)Nrrr%z%1.3er'z%1.3fr z%1.2fgj@z%1.1fz%1.1errrrh.z%se%d)rr?rrrv)r+rYdrrvtupmantissars r-rdzLogFormatter._pprint_vals q6Ctj|tj|jz }dt|cxkrdkrOnnLtj||z tj|jz }|j ||}|S|d}|S)Nr'rcz1.0g)rrZrSrrd)r+rYr8r9rofdrvs r-rez#LogFormatterExponent._num_to_string+s XXa[488DJJ/ / B 5 $+&$**)==B  R(Ad)Ar/N)rHrIrJr{rerEr/r-rr&s r/rceZdZdZdZddZy)rr}cd|||fzS)'Return string for non-decade locations.z$\mathdefault{%s%s^{%.2f}}$rE)r+ sign_stringrOrors r-_non_decade_formatz'LogFormatterMathtext._non_decade_format:s-dB0GGGr/Ncb|dk(ry|dkrdnd}t|}|j}tj|tj|z }t |}|r t |nt j|}t |||z z}|jr|sy|j||jvry|r t |}|dzdk(rd|z} nd|z} t|tjd krd ||fzS|s'tjd } |j|| || Sd || |fzS) Nrz$\mathdefault{0}$rrrkr'rgrz%szaxes.formatter.min_exponentz$\mathdefault{%s%g}$rz$\mathdefault{%s%s^{%d}}$) rrSrrZrlrrrrPrMrsrtr) r+rYrZrrrorprrqrOrs r-r[zLogFormatterMathtext.__call__>s* 6'Uc F JJXXa[488A; &&r* +59"aBM*+   k ?? &5+G rB q5C<!8D!8D r7S\\"?@ @*k1-== =\\-0F**;b&I I/;b2II Ir/r1)rHrIrJr{rr[rEr/r-rr5sH#Jr/rceZdZdZdZy)rzL Format values following scientific notation in a logarithmic axis. ct|}tj|}|||z z}t|r t |}d||||fzS)rz!$\mathdefault{%s%g\times%s^{%d}}$)r*rrrlr)r+rrOrorrrrqs r-rz*LogFormatterSciNotation._non_decade_formatisP $K::b>b8m$ E "%LE3E423 3r/N)rHrIrJr{rrEr/r-rrds 3r/rc^eZdZdZdddddddZdZd Zd Zd Zd Z dd Z dZ ddZ dZ y)rz2 Probability formatter (using Math text). Fz \frac{1}{2}) use_overlineone_halfminorminor_threshold minor_numberch||_||_||_t|_||_||_y)a Parameters ---------- use_overline : bool, default: False If x > 1/2, with x = 1 - v, indicate if x should be displayed as $\overline{v}$. The default is to display $1 - v$. one_half : str, default: r"\\frac{1}{2}" The string used to represent 1/2. minor : bool, default: False Indicate if the formatter is formatting minor ticks or not. Basically minor ticks are not labelled, except when only few ticks are provided, ticks with most space with neighbor ticks are labelled. See other parameters to change the default behavior. minor_threshold : int, default: 25 Maximum number of locs for labelling some minor ticks. This parameter have no effect if minor is False. minor_number : int, default: 6 Number of ticks which are labelled when the number of ticks is below the threshold. N) _use_overline _one_half_minorr\ _labelled_minor_threshold _minor_number)r+rrrrrs r-r.zLogitFormatter.__init__ys4B*!  /)r/c||_y)a Switch display mode with overline for labelling p>1/2. Parameters ---------- use_overline : bool If x > 1/2, with x = 1 - v, indicate if x should be displayed as $\overline{v}$. The default is to display $1 - v$. Nr)r+rs r-rzLogitFormatter.use_overlines *r/c||_y)zz Set the way one half is displayed. one_half : str The string used to represent 1/2. N)r)r+rs r- set_one_halfzLogitFormatter.set_one_halfs "r/c||_y)a  Set the threshold for labelling minors ticks. Parameters ---------- minor_threshold : int Maximum number of locations for labelling some minor ticks. This parameter have no effect if minor is False. N)r)r+rs r-set_minor_thresholdz"LogitFormatter.set_minor_thresholds !0r/c||_y)a Set the number of minor ticks to label when some minor ticks are labelled. Parameters ---------- minor_number : int Number of ticks which are labelled when the number of ticks is below the threshold. N)r)r+rs r-set_minor_numberzLogitFormatter.set_minor_numbers *r/ctj|_|jj |j syt dDryt|jkrZt|jkr|jjytjtjd|jz dz  }tjtjtjf|ftj|tjfftjd|ftj|dfzt!t#t|jfd|j d}|jjfd|Dyy)Nc3K|]Y}t|dxsFtd|z dxs4td|zxr$ttjd|zdk([yw)Hz>rtolr'rN) _is_decaderlr?rr)rrYs r-rz*LogitFormatter.set_locs..sh  qt $ +!a%d+ + Q'*BHHQUO$) + sAA!r'rGc||fSr1rE)r`space_pessimistic space_sums r-z)LogitFormatter.set_locs..s#4Q#71"Fr/)keyc3(K|] }| ywr1rE)rr`ros r-rz*LogitFormatter.set_locs..s%B!d1g%Bs)rarrayrorclearrallrrrupdatediffrZminimum concatenateinfr'range)r+ror good_minorrrs ` @@r-r]zLogitFormatter.set_locssdHHTN  {{      t9t,, ,4y4---%%d+wwq499}q'8 99:$&JJNNRVVIt#45NND266)#45%! NND$<0nndD\23$#dii.)F%%%&( %%%Bz%BB3 -r/c|r+tjtj|}d}nd}d}|d| zz}t |dkr|}ntj tj ||z d}tj| |z}t|rttj|ntj|}||kr|}d||fz} |s| Sd| |fz} | S)Nrr'r rz%.*fz%s\cdot10^{%d}) rrrrrsortrrlr?rr,) r+rYro sci_notationr min_precisionra precisionrr{rvs r- _format_valuezLogitFormatter._format_values zz"((1+.HMHMBH9%% t9q=%I77266$(+,Q/D$(2I$I.BHHY'(YYy)  =() i//O 8 4 4r/c.|jrd|zSd|S)Nz \overline{%s}1-r)r+rvs r- _one_minuszLogitFormatter._one_minuss!   #a' 's8Or/Nc|jr||jvry|dks|dk\rytd|zr"td|zdk(r|j}d |zS|dkr5t |dr(tt j|}d|z}d |zS|dkDrJt d|z dr:tt jd|z }|jd|z}d |zS|d kr!|j||j}d |zS|d kDr6|j|jd|z d|jz }d |zS|j||jd }d |zS)Nrkrr'r?rrz10^{%d}皙??F)rr=) rrrlrrrrrrrro)r+rYrZrvrs r-r[zLogitFormatter.__call__sq ;;1DNN2 6Q!V AE "uQU|q'8A%q((WAD1TZZ]+HH$A%q((WAE5TZZA./H H 45A%q(( W""1dii0A %q(( W 2 21Q3$)) DEA%q((""1diie"DA$q((r/c8|dkr|dS|dkr|dSdd|z dS)Nrrrr<rr'rErds r-rhz LogitFormatter.format_data_short.s9 3;AY  3;AY AIa=!!r/)Tr1)rHrIrJr{r.rrrrr]rrr[rhrEr/r-rrtsM&*P *" 0 *(CT4 )*"r/rceZdZdZidddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(Zd2d)d)d*d+fd, Zd3d-Zd.Zd/Zd0Z d1Z xZ S)4rz Format axis values using engineering prefixes to represent powers of 1000, plus a specified unit, e.g., 10 MHz instead of 1e7. iqiriyizir ir<ipir4iµmrrkr9krMrDG TPEZYRQ)NF)rrrcV||_||_||_t|||d|y)a$ Parameters ---------- unit : str, default: "" Unit symbol to use, suitable for use with single-letter representations of powers of 1000. For example, 'Hz' or 'm'. places : int, default: None Precision with which to display the number, specified in digits after the decimal point (there will be between one and three digits before the decimal point). If it is None, the formatting falls back to the floating point format '%g', which displays up to 6 *significant* digits, i.e. the equivalent value for *places* varies between 0 and 5 (inclusive). sep : str, default: " " Separator used between the value and the prefix/unit. For example, one get '3.14 mV' if ``sep`` is " " (default) and '3.14mV' if ``sep`` is "". Besides the default behavior, some other useful options may be: * ``sep=""`` to append directly the prefix/unit to the value; * ``sep="\N{THIN SPACE}"`` (``U+2009``); * ``sep="\N{NARROW NO-BREAK SPACE}"`` (``U+202F``); * ``sep="\N{NO-BREAK SPACE}"`` (``U+00A0``). usetex : bool, default: :rc:`text.usetex` To enable/disable the use of TeX's math mode for rendering the numbers in the formatter. useMathText : bool, default: :rc:`axes.formatter.use_mathtext` To enable/disable the use mathtext for rendering the numbers in the formatter. useOffset : bool or float, default: False Whether to use offset notation with :math:`10^{3*N}` based prefixes. This features allows showing an offset with standard SI order of magnitude prefix near the axis. Offset is computed similarly to how `ScalarFormatter` computes it internally, but here you are guaranteed to get an offset which will make the tick labels exceed 3 digits. See also `.set_useOffset`. .. versionadded:: 3.10 F)rrrrN)unitplacesseprr.)r+rrrrrrrs r-r.zEngFormatter.__init__Ws9Z   #  r/c&t|jdk(s|jdk(r |j|j |S||jz d|j zz }t |dkrd}|j|j|S)z Return the format for tick value *x* at position *pos*. If there is no currently offset in the data, it returns the best engineering formatting that fits the given argument, independently. rrr) rrorrwrerrrrrs r-r[zEngFormatter.__call__s} tyy>Q $++"2>>$"2"21"56 6dkk/cT-B-B&BCB2w~66t{{BG Gr/c||_t|jdkDrt|jj \}}|j r6|j |jdk7rt||zdz d|_tjtj||z ddz|_ |jyy)Nrrr9)rorr'rMr4rrrrrrrZrr)r+ror8r9s r-r]zEngFormatter.set_locss tyy>A  ; ; =>JD$$$&;;!##(a";DK$(JJtxxt T/J$KA$MD !     r/ct|jdk(ry|jrd}|jr/|j|j}|jdkDrd|z}|jd|jz}|j s |j r|dk7rd|z}d||d}n||z}|j|Sy)Nrrkrr z\times%sr)rrorrerrrrwrs r-rlzEngFormatter.get_offsets tyy>Q  ;;I{{ ,,T[[9 ;;? #iI((t/D/D)DEI  DLL? +i 7I {9+Q/ )>>!$ $r/c$|j|S)z!Alias to EngFormatter.format_datarg)r+nums r- format_engzEngFormatter.format_engs$$r/cd}|jdnd|jdd}|dkrd}| }|dk7r8ttjtj|dz dz}nd}d }t j |t|jt|j}||zd |zz }ttt||d k\r"|t|jkr |d z}|dz }|jt|}|js|r|j||j}nd }|js |j r d ||d d |S||d |S)u{ Format a number in engineering notation, appending a letter representing the power of 1000 of the original number. Some examples: >>> format_data(0) # for self.places = 0 '0' >>> format_data(1000000) # for self.places = 1 '1.0 M' >>> format_data(-1e-6) # for self.places = 2 '-1.00 µ' r'rrxryr<rrr9rgrrrkr)rr?rrrrclipr) ENG_PREFIXESrrr*rrrrr)r+rar2rpow10mant unit_prefixsuffixs r-rezEngFormatter.format_datask[[(c$++a.B 19DFE A: 4::e#4q#89A=>EEEs4#4#45s4;L;L7MNe|tu}- fT3'( )T 1C 1 122 DLD QJE''E 3 99 z+tyyk:FF <<4,,tSE6l!F8, ,C5&\&* *r/)rkN r1) rHrIrJr{rr.r[r]rlrrerrs@r-rr8s  S S S S  S  S  S S  S R S S S S S!" S#$   +L05 !U5 n H2(%2+r/rc`eZdZdZd dZd dZdZdZedZ e jdZ y) ra Format numbers as a percentage. Parameters ---------- xmax : float Determines how the number is converted into a percentage. *xmax* is the data value that corresponds to 100%. Percentages are computed as ``x / xmax * 100``. So if the data is already scaled to be percentages, *xmax* will be 100. Another common situation is where *xmax* is 1.0. decimals : None or int The number of decimal places to place after the point. If *None* (the default), the number will be computed automatically. symbol : str or None A string that will be appended to the label. It may be *None* or empty to indicate that no symbol should be used. LaTeX special characters are escaped in *symbol* whenever latex mode is enabled, unless *is_latex* is *True*. is_latex : bool If *False*, reserved LaTeX characters in *symbol* will be escaped. NcB|dz|_||_||_||_y)Nrg)xmaxr;_symbol _is_latex)r+rr;symbolis_latexs r-r.zPercentFormatter.__init__s"3J    !r/c|jj\}}t||z }|j|j ||S)z=Format the tick as a percentage with the appropriate scaling.)rMr4rrw format_pct)r+rYrZax_minax_max display_ranges r-r[zPercentFormatter.__call__#s@446FVO, ~~dooa?@@r/cB|j|}|jW|j|}|dkrd}nJtjdtjd|zz }|dkDrd}n|dkrd}n |j}|dt |d}||j zS)a| Format the number as a percentage number with the correct number of decimals and adds the percent symbol, if any. If ``self.decimals`` is `None`, the number of digits after the decimal point is set based on the *display_range* of the axis as follows: ============= ======== ======================= display_range decimals sample ============= ======== ======================= >50 0 ``x = 34.5`` => 35% >5 1 ``x = 34.5`` => 34.5% >0.5 2 ``x = 34.5`` => 34.50% ... ... ... ============= ======== ======================= This method will not be very good for tiny axis ranges or extremely large ones. It assumes that the values on the chart are percentages displayed on a reasonable scale. r@z0.r<)convert_to_pctr;rr,rr?r)r+rYr scaled_ranger;rvs r-rzPercentFormatter.format_pct)s,    " == ..}=Lq   99S4::cL6H+I%IJa< H\ H}}HCM?!#$4;;r/c&d||jz zS)NgY@)r)r+rYs r-rzPercentFormatter.convert_to_pctUsDII &&r/c|j}|sd}|S|js/tjdrdD]}|j |d|z}|S)z The configured percent symbol as a string. If LaTeX is enabled via :rc:`text.usetex`, the special characters ``{'#', '$', '%', '&', '~', '_', '^', '\', '{', '}'}`` are automatically escaped in the string. rkrz \#$%&~_^{}\)rrrsrtru)r+rspecs r-rzPercentFormatter.symbolXsZF CLL$?& ;dTk: ; r/c||_yr1)r)r+rs r-rzPercentFormatter.symbolls  r/)dN%Fr1) rHrIrJr{r.r[rrrErsetterrEr/r-rrsI2" A *X'& ]]r/rc8eZdZdZdZdZdZdZdZdZ dZ y ) rz Determine tick locations. Note that the same locator should not be used across multiple `~matplotlib.axis.Axis` because the locator stores references to the Axis data and view limits. rctd)a Return the values of the located ticks given **vmin** and **vmax**. .. note:: To get tick locations with the vmin and vmax values defined automatically for the associated ``axis`` simply call the Locator instance:: >>> print(type(loc)) >>> print(loc()) [1, 2, 3, 4] rUrVr7s r- tick_valueszLocator.tick_valuess""9::r/c Xtjdtt|zy)z Do nothing, and raise a warning. Any locator class not supporting the set_params() function will call this. z/'set_params()' not defined for locator of type N)rrrtyperPs r- set_paramszLocator.set_paramss%  = T O  r/ctd)"Return the locations of the ticks.rUrVr3s r-r[zLocator.__call__s""9::r/ct||jk\r2tjdt||d|d|j|S)a Log at WARNING level if *locs* is longer than `Locator.MAXTICKS`. This is intended to be called immediately before returning *locs* from ``__call__`` to inform users in case their Locator returns a huge number of ticks, causing Matplotlib to run out of memory. The "strange" name of this method dates back to when it would raise an exception instead of emitting a log. z]Locator attempting to generate %s ticks ([%s, ..., %s]), which exceeds Locator.MAXTICKS (%s).rr)rMAXTICKS_logwarningrps r-raise_if_exceedszLocator.raise_if_exceedssE t9 % LL7D 47DHdmm = r/c2tj||dS)a1 Adjust a range as needed to avoid singularities. This method gets called during autoscaling, with ``(v0, v1)`` set to the data limits on the Axes if the Axes contains any data, or ``(-inf, +inf)`` if not. - If ``v0 == v1`` (possibly up to some floating point slop), this method returns an expanded interval around this value. - If ``(v0, v1) == (-inf, +inf)``, this method returns appropriate default view limits. - Otherwise, ``(v0, v1)`` is returned without modification. rirjrmrn)r+v0v1s r-rnzLocator.nonsingulars&&r2<JJt$  tyy1&+&7S] T r/c|||_yy#Set parameters within this locator.Nr,)r+r,s r-rzFixedLocator.set_paramss  DJ r/c&|jddSr1r r3s r-r[zFixedLocator.__call__d++r/c |j |jSttt j t |j|jz d}|jdd|}td|D]^}|j|d|}t j|jt j|jks]|}`|j|S)z Return the locations of the ticks. .. note:: Because the values are fixed, vmin and vmax are not used in this method. Nr') r,rorr?rr,rrrr)r)r+r8r9stepticksr`ticks1s r-r zFixedLocator.tick_valuess :: 99 3rwws499~ :;s r-r.zLinearLocator.__init__3s! ?DL"DLr/c6|j |jSdS)N  _numticksr3s r-r=zLinearLocator.numticksDs"&!;t~~CCr/c||_yr1rB)r+r=s r-r=zLinearLocator.numticksIs !r/c*|||_|||_yyr.)r>r=r?s r-rzLinearLocator.set_paramsMs!  "DL  $DM r/c`|jj\}}|j||SrrMr4r r7s r-r[zLinearLocator.__call__Tr%r/ctj||d\}}||f|jvr|j||fS|jdk(rgSt j |||j}|j |S)Nrirjr)rmrnr>r=rlinspacer)r+r8r9ticklocss r-r zLinearLocator.tick_valuesYsu ,,T4$G d $<4<< '<<t - - ==A I;;tT4==9$$X..r/c ||kr||}}||k(r |dz}|dz }tjddk(rttj||z tjt |j dz d\}}||dkz}t |j dz d| z}tj||z|z }tj||z|z }tj||S),Try to choose the view limits intelligently.r'axes.autolimit_mode round_numbersr) rsrtdivmodrrrr=rr,rmrn)r+r8r9r remainderscales r-rzLinearLocator.view_limitses $;t$D 4< AID AID <<- ./ A"( 4$;'C 8I14M)N#P Hi R (H )1-8) 0, default: 1.0 Interval between ticks. offset : float, default: 0.0 Value added to each multiple of *base*. .. versionadded:: 3.8 rN _Edge_integer_edge_offsetrs r-r.zMultipleLocator.__init__s#4+  r/Nc>|t|d|_|||_yy)a Set parameters within this locator. Parameters ---------- base : float > 0, optional Interval between ticks. offset : float, optional Value added to each multiple of *base*. .. versionadded:: 3.8 NrrUrs r-rzMultipleLocator.set_paramss*  &tQ/DJ  !DL r/c`|jj\}}|j||SrGrHr7s r-r[zMultipleLocator.__call__r%r/cR||kr||}}|jj}||jz}||jz}|jj||z}||z d|zz|z}||z t j |dz|zz|jz}|j |S)Nr:r9)rWr5rXgerr]r)r+r8r9r5r4ros r-r zMultipleLocator.tick_valuess $;t$Dzz    zz}}T"T) D[54< 'D 0d{RYYq1u-44t||C$$T**r/ctjddk(r|jj||jz |jj z|jz}|jj ||jz |jj z|jz}||k(r|dz}|dz }n|}|}tj||S)zW Set the view limits to the nearest tick values that contain the data. rNrOr') rsrtrWlerXr5r\rmrn)r+r#r$r8r9s r-rzMultipleLocator.view_limitss <<- ./ A::== !45 G$,,VD::== !45 G$,,VDt|  DD&&tT22r/)?rgr' rHrIrJr{r.rr[r rrEr/r-rrzs  "$, +3r/rc t||z }||zdz }t||z |krd}n8tjdtjt|dzz|}dtj||z dzz}||fS)Nrrr r')rrr+r)r8r9r4 thresholddvmeanvrrRs r- scale_rangeres TD[ B D[A E 5zB"rdjjU&<&ABEJ 4::b1f%* +E &=r/c(eZdZdZdZdZdZdZy)rVz Helper for `.MaxNLocator`, `.MultipleLocator`, etc. Take floating-point precision limitations into account when calculating tick locations as integer multiples of a step. cR|dkr td||_t||_y)z Parameters ---------- step : float > 0 Interval between ticks. offset : float Offset subtracted from the data limits prior to calculating tick locations. rz'step' must be positiveN)rr5rrX)r+r5rs r-r.z_Edge_integer.__init__s) 1967 7 6{ r/c|jdkDrKtj|j|jz }t dd|dz z}t d|}nd}t ||z |kS)Nrg|=r rg= x.rr'rorps r-r\z_Edge_integer.ges:a#1 <<DII q )H1u r/N)rHrIrJr{r.rmr^r\rEr/r-rVrVs #$r/rVcreZdZdZeddddddZddZedZed Z d Z d Z d Z d Z dZy)rz Place evenly spaced ticks, with a cap on the total number of ticks. Finds nice tick locations with no more than :math:`nbins + 1` ticks being within the view limits. Locations beyond the limits are added to support autoscaling. r NFr)r,stepsinteger symmetricprune min_n_ticksc R|||d<|jdii|j|y)aj Parameters ---------- nbins : int or 'auto', default: 10 Maximum number of intervals; one less than max number of ticks. If the string 'auto', the number of bins will be automatically determined based on the length of the axis. steps : array-like, optional Sequence of acceptable tick multiples, starting with 1 and ending with 10. For example, if ``steps=[1, 2, 4, 5, 10]``, ``20, 40, 60`` or ``0.4, 0.6, 0.8`` would be possible sets of ticks because they are multiples of 2. ``30, 60, 90`` would not be generated because 3 does not appear in this example list of steps. integer : bool, default: False If True, ticks will take only integer values, provided at least *min_n_ticks* integers are found within the view limits. symmetric : bool, default: False If True, autoscaling will result in a range symmetric about zero. prune : {'lower', 'upper', 'both', None}, default: None Remove the 'lower' tick, the 'upper' tick, or ticks on 'both' sides *if they fall exactly on an axis' edge* (this typically occurs when :rc:`axes.autolimit_mode` is 'round_numbers'). Removing such ticks is mostly useful for stacked or ganged plots, where the upper tick of an Axes overlaps with the lower tick of the axes above it. min_n_ticks : int, default: 2 Relax *nbins* and *integer* constraints if necessary to obtain this minimum number of ticks. Nr,rE)rdefault_params)r+r,rQs r-r.zMaxNLocator.__init__s6F  #F7O<;T00;F;s/~~sU3BZ/eAhHIIr/c d|vr?|jd|_|jdk7rt|j|_d|vr|jd|_d|vr1|jd}t j gd|||_d|vr td|jd|_d |vrf|jd }|tjgd |_ n|j||_ |j|j|_d |vr|jd |_|rt j d |y )a Set parameters for this locator. Parameters ---------- nbins : int or 'auto', optional see `.MaxNLocator` steps : array-like, optional see `.MaxNLocator` integer : bool, optional see `.MaxNLocator` symmetric : bool, optional see `.MaxNLocator` prune : {'lower', 'upper', 'both', None}, optional see `.MaxNLocator` min_n_ticks : int, optional see `.MaxNLocator` r,autorurv)upperlowerbothN)rvrwr'rsN) r'g?r@r9rrr rtr)pop_nbinsr? _symmetricr check_in_list_pruner _min_n_ticksrr_stepsr~r_extended_steps_integer kwarg_error)r+rQrvrss r-rzMaxNLocator.set_paramsDs$& f  **W-DK{{f$!$++. & $jj5DO f JJw'E   ?u MDK F " #Avzz-'@ AD  f JJw'E} hh'JK "2259 #'??4;;#?D  "JJy1DM ""<8 8 r/c |jdk(rV|jGtj|jj t d|j dz d}nd}n |j}t|||\}}||z }||z }|j|z}|jr9|dktj|tj|z dkz} || }||z |z } t|jdr+|jjjdk(r| dzd z } || k\} tj d d k(r||z|z} | ||zz} | | |k\z} t#| rtj$| d d }nt'|dz }|d|dzddd D]}|jrGtj(|tj*|z |j dz k\r t d|}||z|z}t-||}|j/||z }|j1||z }tj2||dz|z|z}||k||k\zj5}||j k\s||zS|zS)z Generate a list of tick locations including the range *vmin* to *vmax*. In some applications, one or both of the end locations will not be needed, in which case they are trimmed off elsewhere. rNr'rDr:r3drrNrOrr)rrMrrrFrrrerrrrhasattrrnamersrtr|nonzerorrr,rVr^r\r]sum)r+r8r9r,rRr_vmin_vmaxrsigoodraw_step large_steps floored_vmins floored_vmaxsistepr5 best_vminrjlowhighr6ntickss r- _raw_tickszMaxNLocator._raw_ticksos ;;& yy$ 8 8 : #At'8'81'< =qBKKE#D$6 vv v $$u, ==QY266%"((5/*A#BU#JKE%LEU]e+ 499f %$))..*=*=*E "}R'Hx' <<- ./ A#e^u4M)EEM9M%%)?@K { JJ{+A.q1EJNE (57ODbD) D HHUObggen48I8IA8MM1d|$$.I !v.D''%)+,C7759,-DIIc4!8,t3i?E~%5.9>>@F***v~' &v~r/c`|jj\}}|j||Sr1rHr7s r-r[zMaxNLocator.__call__s+YY002 dd++r/c2|jr!tt|t|}| }tj||dd\}}|j ||}|j }|dk(r|dd}n|dk(r|dd}n |dk(r|dd}|j|S) NvIh%<=g+=rktinyrr'rrr)rrrrmrnrrr)r+r8r9rorvs r-r zMaxNLocator.tick_valuess ??s4y#d),D5D ,, $U4 dtT*  G 8D g 9D f_":D$$T**r/c|jr!tt|t|}| }tj||dd\}}t j ddk(r|j||ddgS||fS)Ng-q=rrrNrOrr)rrrrmrnrsrtrr"s r-rzMaxNLocator.view_limitssy ??s4y#d),D5D ,, $U4 d <<- ./ A??4.2w7 7: r/r1)rHrIrJr{dictryr.r|r~rrrr[r rrEr/r-rrsp  $"'$) $&' )N%=N  JJ )9VCJ,+" r/rr )rOrcNtj|sy|dk(rytjt|tj|z }|)tj|tj |Stj|tj ||S)z1Return True if *x* is an integer power of *base*.FrgTr)risfiniterZriscloser)rYrOrlxs r-rrsq ;;q>Cx A"&&, &B |zz"bhhrl++zz"bhhrl66r/c|dk(r|S|dkrt| | S|tjtj|tj|z zS)z Return the largest integer power of *base* that's less or equal to *x*. If *x* is negative, the exponent will be *greater*. r)_decade_greater_equalrrrZrYrOs r-_decade_less_equalrsX aA801A "A2t , ,8 BHHRVVAY56 68r/c|dk(r|S|dkrt| | S|tjtj|tj|z zS)z Return the smallest integer power of *base* that's greater or equal to *x*. If *x* is negative, the exponent will be *smaller*. r)rrr,rZrs r-rrsX aA7-.U D ) )7 BGGBFF1It 45 57r/cX|dkrt| | St||}||k(r||z}|S)z Return the largest integer power of *base* that's less than *x*. If *x* is negative, the exponent will be *greater*. r)_decade_greaterr)rYrOlesss r- _decade_lessrs>  1uD))) a &D qy   Kr/cX|dkrt| | St||}||k(r||z}|S)z Return the smallest integer power of *base* that's greater than *x*. If *x* is negative, the exponent will be *smaller*. r)rr)rYrOgreaters r-rr s>  1uaR&&&#At,G!|4 Nr/c@tj|t|Sr1)rrrrYs r-rlrl s <<58 $$r/cJeZdZdZd dddZd dddZdZdZdZd Z d Z y) rzd Place logarithmically spaced ticks. Places ticks at the values ``subs[j] * base**i``. N)r=c|tjdrd}nd}t||_|j |||_y)a Parameters ---------- base : float, default: 10.0 The base of the log used, so major ticks are placed at ``base**n``, where ``n`` is an integer. subs : None or {'auto', 'all'} or sequence of float, default: (1.0,) Gives the multiples of integer powers of the base at which to place ticks. The default of ``(1.0, )`` places ticks only at integer powers of the base. Permitted string values are ``'auto'`` and ``'all'``. Both of these use an algorithm based on the axis view limits to determine whether and how to put ticks between integer powers of the base: - ``'auto'``: Ticks are placed only between integer powers. - ``'all'``: Ticks are placed between *and* at integer powers. - ``None``: Equivalent to ``'auto'``. numticks : None or int, default: None The maximum number of ticks to allow on a given axis. The default of ``None`` will try to choose intelligently as long as this Locator has already been assigned to an axis using `~.axis.Axis.get_tick_space`, but otherwise falls back to 9. NrHrr)rsrtr*rS _set_subsr=r+rOsubsr=s r-r.zLogLocator.__init__! s?,  ||45!4[  t  r/cb|t||_||j||||_yyr.)r*rSrr=rs r-rzLogLocator.set_params@ s7  tDJ   NN4  $DM r/cr|d|_yt|trtjd|||_y t j |t|_|jjdk7r#td |jjd y#t$r}td|d|d}~wwxYw) zT Set the minor ticks for the log scaling every ``base**i*subs[j]``. Nr)rr)r)dtypez>subs must be None, 'all', 'auto' or a sequence of floats, not rxr'z5A sequence passed to subs must be 1-dimensional, not z -dimensional.) _subsrrrrrr(r*rndim)r+rrs r-rzLogLocator._set_subsI s <DJ c "   T :DJ 4ZZE: zz!# "7$(JJOO#4M"CDD$  4 ">$(6",-234 4s B B6!B11B6c`|jj\}}|j||SrGrHr7s r-r[zLogLocator.__call__^ r%r/c|jdk(r?|j0tj|jj dd}nd}n |j}|j }|dkrK|j|jj }|dkstj|s tdtjd||||kr||}}tj|tj|z }tj|tj|z }tj|tj|z }t|j t"ro|dkDs|dkr;|j dk(rtj$gStj$d g}n6|j dk(rd nd } tj&| |}n |j }t(j*d r%t-tj||d z z d n||zd z} | |k\rt-d |d z } t/|d kDxst/|d k(xr|d d k7} tj&tj|| z tj|d| zz| } | rE| d k(r*tj0|| zD cgc]} || z c} }ntj$g}n|| z}tjd|t/|d kDr;| d k(r6||k||kzj3d krt5j7||S|j9|Scc} w)NrrrDrg@Data has no positive values, and therefore cannot be log-scaled.zvmin %s vmax %sr r9r_rrHr'rz ticklocs %r)r=rMrrrFrSr=rrrdebugrrZrr,rrrrr]rsrtrrrrrr r)r+r8r9r=rlog_vminlog_vmaxr^r_firststride have_subsdecades decade_startrKs r-r zLogLocator.tick_valuesc s ==F "yy$77499#;#;#=q!D}}H JJ 3;yy$yy++-s{"++d"3 VXX $dD1 $;t$D88D>DHHQK/88D>DHHQK/H% ((;; djj# &{a!e::'88B<'88SE?D $ f 4#yy+::D\\":;dii(Q, 78!<H$q(  V FQJ'FIMHc$i1n&GaC ))DJJx069 IIh/!f*>=>'\J\TL(JL88B<G|H =(+ IMaKh&8t+;<AACqH=,,T48 8((2 2Ks M+c|j}|j||\}}tjddk(rt ||}t ||}||fSrMrNrO)rSrnrsrtrrr+r8r9rs r-rzLogLocator.view_limits sU JJ%%dD1 d <<- ./ A%dA.D(q1DTzr/c||kDr||}}tj|rtj|s d\}}||fS|dkrtjdd\}}||fSt d|j j D}tj|sd}|dkr|}||k(r,t||j}t||j}||fS)N)r'r rrc3<K|]}|jywr1)r=)rrMs r-rz)LogLocator.nonsingular.. sTt*TsgYn) rrrrr)rM_get_shared_axisrrSr)r+r8r9r,s r-rnzLogLocator.nonsingular s $;t$D{{4  D(9JD$ TzQY    JD$TzTtyy7Q7Q7STTF;;v&qyt|#D$**5&tTZZ8Tzr/)r)r_r') rHrIrJr{r.rrr[r rrnrEr/r-rr s; !4!>%4%D*, L3\ r/rc2eZdZdZddZd dZdZdZdZy) r z^ Place ticks spaced linearly near zero and spaced logarithmically beyond a threshold. Nc|#|j|_|j|_n||||_||_n t d|dg|_d|_y||_d|_y)a Parameters ---------- transform : `~.scale.SymmetricalLogTransform`, optional If set, defines the *base* and *linthresh* of the symlog transform. base, linthresh : float, optional The *base* and *linthresh* of the symlog transform, as documented for `.SymmetricalLogScale`. These parameters are only used if *transform* is not set. subs : sequence of float, default: [1] The multiples of integer powers of the base where ticks are placed, i.e., ticks are placed at ``[sub * base**i for i in ... for sub in subs]``. Notes ----- Either *transform*, or both *base* and *linthresh*, must be given. Nz?Either transform, or both linthresh and base, must be provided.r_r)rOrSrQrNrrr=)r+rrrQrOs r-r.zSymmetricalLogLocator.__init__ st&  "DJ'11DO  "t'7DJ'DO;< < <DJ DJ r/c*|||_|||_yyr.)r=r)r+rr=s r-rz SymmetricalLogLocator.set_params s!  $DM  DJ r/c`|jj\}}|j||SrGrHr7s r-r[zSymmetricalLogLocator.__call__ s-YY002 dd++r/c |j}||kr||}}| |cxkr |cxkr|krnnt|d|hS|| k}||kD}|xr|| kDxs |xr||k}|jfd}d\}} |r.t| |} |t | t |dz\}} d\} } |rt ||} || |dz\} } | |z | | z z}|r|dz }t ||j dz zd}g}|r2|jdtj|| |dddzz|r|jd|r)|jtj| | |ztj|j}t|dkDs|ddk7r5g}|D]-}|dk(r|j||j||z/n|}|jtj|S)Nrctjtj|tjz }tjtj|tjz }||fSr1)rrrZr,)lohirOs r- get_log_rangez8SymmetricalLogLocator.tick_values..get_log_range/ sR"&&*rvvd|34BbffTl23Br6Mr/rIr'rrgr_)rNr'rSr)rrr=extendrr]appendr(rrrr)r+r8r9rQhas_ahas_chas_bra_loa_hi a_upper_limc_loc_hi c_lower_lim total_ticksrrrrKdecaderOs @r-r z!SymmetricalLogLocator.tick_values s OO $;t$D* : 1 1 14D/* * " !,49*,M%2LD9 >@#FGB  d.?.?)?!@ @7[[ ) 0yy1} ))rxxs2w$((499BU0U'VVW<@IIRXXdDII.6684xxB#b'9J0K,KLBHHR$Y// 0B)E auSR[[tT]]-SS 0 0s 6D%I;;J)rAg?r Nr) rHrIrJr{r.rr[r rrs@r-r!r!n s. =@#>37#' 80Tr/r!czeZdZdZd ddfd Zd fd ZedZejdZfdZ d Z xZ S) r"z5 Place ticks spaced evenly on a logit scale. rr0c:||_t| |gdy)z Parameters ---------- nbins : int or 'auto', optional Number of ticks. Only used if minor is False. minor : bool, default: False Indicate if this locator is for minor ticks or not. r'rrr r,rsN)rrr.)r+rr,rs r-r.zLogitLocator.__init__ s  uM:r/c 6|||_t|di|y)r/NrE)rrr)r+rrQrs r-rzLogitLocator.set_params s  DK $V$r/c|jSr1)rr3s r-rzLogitLocator.minor s {{r/c(|j|y)N)r)rrds r-rzLogitLocator.minor s e$r/cNt|jdr.|jjjdk(r t d|j dk(r1|j"|jj }|dkrd}nd}n |j }d}|j||\}}t|dkr(tjtj|n2|d krd n+tjtjd |z  }t|dkr(tjtj|n2|d krd n+tjtjd |z  }||z d z }|dk\r||kDrtj||z }|jr+t||d zD cgc]} | |zd k7r|| } } n*t||d zD cgc]} | |zd k(r|| } } |j!tj"| S|jrg} t||D]} | d kr,| j%tj&dd d | zz4| d k(r)| j%tj&ddd z b| d k(r)| j%tj&ddd z | j%d tj&dd ddd d | d z zzz |j!tj"| St||d zD cgc] } ||  } } |j!tj"| S|jrgSt( |U||Scc} wcc} wcc} w)Nrpolarz%Polar axis cannot be logit scaled yetrrrDc6|dkrd|zS|dkDr dd| zz SdS)Nrr r'rrErs r- ideal_ticksz-LogitLocator.tick_values..ideal_ticks s-!e27 KQUbaRj)9 K Kr/rrrr'rr rr)rrMrrrWrrFrnr?rrrr,rrrrrrr]rr ) r+r8r9r,rbinfbsupnumidealsubsampling_factorrrKrs r-r zLogitLocator.tick_values sO 499f %$))..*=*=*H%&MN N ;;& yy$ 00219EKKE  L%%dD1 dcz HHRXXd^ $cz''"((1t8,--  s{ GGBHHTN #s{((288AH-..  $;? q=%&*YYx%/?%@";;"'tTAX!6  22q8$A H "'tTAX!6  22q8$A H  ,,RXXh-?@@{{tT* A2v  !R(827(BCb  !Q"(<=a  !Q"(<=  !R 02 6Q GG ,,RXXh-?@@05dD1H0EF1 AFHF((();< < ;;Iw"4..?   (GsN/NN"cd}|d|z f}||kDr||}}tj|rtj|s |\}}||fS|dks|dk\rtjd|\}}||fS|j|jj n|}tj|s|}|dkr|}|dk\rd|z }||k(r d|zdd|zz }}||fS)Nrr'rzIData has no values between 0 and 1, and therefore cannot be logit-scaled.r)rrrrrMr=)r+r8r9standard_minpos initial_ranger,s r-rnzLogitLocator.nonsingular7 s (!o*=> $;t$D{{4  D(9&JD$8Tz7QY$!)     'JD$(Tz!99( $$&$  ;;v&(qy qy6zt| 4ZS4ZdTzr/)Fr1) rHrIrJr{r.rrErrr rnrrs@r-r"r" sQ ;V ;%  \\%%K/Z"r/r"c"eZdZdZfdZxZS)rz Place evenly spaced ticks, with the step size and maximum number of ticks chosen automatically. This is a subclass of `~matplotlib.ticker.MaxNLocator`, with parameters *nbins = 'auto'* and *steps = [1, 2, 2.5, 5, 10]*. chtjdrd}gd}nd}gd}t| ||y)z To know the values of the non-public parameters, please have a look to the defaults of `~matplotlib.ticker.MaxNLocator`. rHrDr r)r'rrrr rN)rsrtrr.)r+r,rsrs r-r.zAutoLocator.__init__d s8 <<0 1E!EE&E uE2r/)rHrIrJr{r.rrs@r-rr\ s 3 3r/rc$eZdZdZddZdZdZy)rz Place evenly spaced minor ticks, with the step size and maximum number of ticks chosen automatically. The Axis must use a linear scale and have evenly spaced major ticks. Nc||_y)aG Parameters ---------- n : int or 'auto', default: :rc:`xtick.minor.ndivs` or :rc:`ytick.minor.ndivs` The number of subdivisions of the interval between major ticks; e.g., n=2 will place a single minor tick midway between major ticks. If *n* is 'auto', it will be set to 4 or 5: if the distance between the major ticks equals 1, 2.5, 5 or 10 it can be perfectly divided in 5 equidistant sub-intervals with a length multiple of 0.05; otherwise, it is divided in 4 sub-intervals. N)ndivs)r+r4s r-r.zAutoMinorLocator.__init__z s  r/c>|jjdk(rtjdgSt j |jj }t|dkrgS|d|dz }|j3tj|jjdk(rdnd|_|jd k(rFd t j|dzz}t j|gd jrd nd }n |j}||z }t|jj!\}}|d}t#||z |z } t#||z |z dz} t j$| | |z|z} |j'| S)NrZz4AutoMinorLocator does not work on logarithmic scalesrr'rrzytick.minor.ndivszxtick.minor.ndivsrr )r'rrr rr)rM get_scalerrruniqueget_majorticklocsrr!rsrt axis_namerrr|r'r4rr]r) r+ majorlocs majorstepmajorstep_mantissar! minorstepr8r9t0tmintmaxros r-r[zAutoMinorLocator.__call__ sp 99   E )   U VIIIdii99;< y>A IaL9Q</ :: '+yy':':c'A#(*DJ :: !#(;a(?!@ $6HLLNATUEJJE% DII779: d q\dRi9,-dRi9,-1 $% 1R7$$T**r/cDtdt|j)Nz Cannot get tick locations for a )rWr rHr7s r-r zAutoMinorLocator.tick_values s&!.tDz/B/B.C DF Fr/r1)rHrIrJr{r.r[r rEr/r-rrr s !+FFr/r)r'r):r{r.loggingrrnumbersrstringnumpyrrrsrrrrm getLoggerrHr__all__r$rrr r r r rr rrrrrrrrrrrrrrrerVrrrrrrrlrr r!r"rrrEr/r-r5sBH  "0w" D8--= = @I!Y!D!I!80 M&** MDD8E>iE>PN9Nb < ,J<,J^ 32 3 A"YA"HH+?H+Vkyk\W3jW3tA7A:*,7*,Z'(N3GN3bC3gC3L,,^Z'Zz4 787  %wwtW3GW3tYT7YTxO;Od3+3,<Fw<Fr/