rL i^dZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZddlmZddlZddlZddlZddlZddlmZmZm Z m!Z!dZ"ejFe$Z%ejLjNZ(dCdZ)e*ejdd d jWZ,ed zZ-d Z.d Z/d Z0d Z1d Z2dZ3dZ4e/e.zZ5e0e/zZ6e6e.zZ7e7e2zZ8de7zZ9eee e e e e f\Z:Z;ZZ?Z@e:e;ee?e@fZAdaBdZCdZDdZEdZFdCdZGejeGdZIejejjZLdCdZMdZNdCdZOejddZPdZQdZRdZSGdd e jZUGd!d"e jZVGd#d$e jZWGd%d&ZXGd'd(e jZZGd)d*eZZ[Gd+d,eZZ\Gd-d.e[Z]Gd/d0e[Z^Gd1d2e[Z_Gd3d4e[Z`Gd5d6e[ZaGd7d8e[ZbGd9d:e[ZcGd;de!jZfGd?d@efZgGdAdBZhehxe!jej<xe!jej<e!jej<y)Da Matplotlib provides sophisticated date plotting capabilities, standing on the shoulders of python :mod:`datetime` and the add-on module dateutil_. By default, Matplotlib uses the units machinery described in `~matplotlib.units` to convert `datetime.datetime`, and `numpy.datetime64` objects when plotted on an x- or y-axis. The user does not need to do anything for dates to be formatted, but dates often have strict formatting needs, so this module provides many tick locators and formatters. A basic example using `numpy.datetime64` is:: import numpy as np times = np.arange(np.datetime64('2001-01-02'), np.datetime64('2002-02-03'), np.timedelta64(75, 'm')) y = np.random.randn(len(times)) fig, ax = plt.subplots() ax.plot(times, y) .. seealso:: - :doc:`/gallery/text_labels_and_annotations/date` - :doc:`/gallery/ticks/date_concise_formatter` - :doc:`/gallery/ticks/date_demo_convert` .. _date-format: Matplotlib date format ---------------------- Matplotlib represents dates using floating point numbers specifying the number of days since a default epoch of 1970-01-01 UTC; for example, 1970-01-01, 06:00 is the floating point number 0.25. The formatters and locators require the use of `datetime.datetime` objects, so only dates between year 0001 and 9999 can be represented. Microsecond precision is achievable for (approximately) 70 years on either side of the epoch, and 20 microseconds for the rest of the allowable range of dates (year 0001 to 9999). The epoch can be changed at import time via `.dates.set_epoch` or :rc:`date.epoch` to other dates if necessary; see :doc:`/gallery/ticks/date_precision_and_epochs` for a discussion. .. note:: Before Matplotlib 3.3, the epoch was 0000-12-31 which lost modern microsecond precision and also made the default axis limit of 0 an invalid datetime. In 3.3 the epoch was changed as above. To convert old ordinal floats to the new epoch, users can do:: new_ordinal = old_ordinal + mdates.date2num(np.datetime64('0000-12-31')) There are a number of helper functions to convert between :mod:`datetime` objects and Matplotlib dates: .. currentmodule:: matplotlib.dates .. autosummary:: :nosignatures: datestr2num date2num num2date num2timedelta drange set_epoch get_epoch .. note:: Like Python's `datetime.datetime`, Matplotlib uses the Gregorian calendar for all conversions between dates and floating point numbers. This practice is not universal, and calendar differences can cause confusing differences between what Python and Matplotlib give as the number of days since 0001-01-01 and what other software and databases yield. For example, the US Naval Observatory uses a calendar that switches from Julian to Gregorian in October, 1582. Hence, using their calculator, the number of days between 0001-01-01 and 2006-04-01 is 732403, whereas using the Gregorian calendar via the datetime module we find:: In [1]: date(2006, 4, 1).toordinal() - date(1, 1, 1).toordinal() Out[1]: 732401 All the Matplotlib date converters, locators and formatters are timezone aware. If no explicit timezone is provided, :rc:`timezone` is assumed, provided as a string. If you want to use a different timezone, pass the *tz* keyword argument of `num2date` to any date tick locators or formatters you create. This can be either a `datetime.tzinfo` instance or a string with the timezone name that can be parsed by `~dateutil.tz.gettz`. A wide range of specific and general purpose date tick locators and formatters are provided in this module. See :mod:`matplotlib.ticker` for general information on tick locators and formatters. These are described below. The dateutil_ module provides additional code to handle date ticking, making it easy to place ticks on any kinds of dates. See examples below. .. _dateutil: https://dateutil.readthedocs.io .. _date-locators: Date tick locators ------------------ Most of the date tick locators can locate single or multiple ticks. For example:: # import constants for the days of the week from matplotlib.dates import MO, TU, WE, TH, FR, SA, SU # tick on Mondays every week loc = WeekdayLocator(byweekday=MO, tz=tz) # tick on Mondays and Saturdays loc = WeekdayLocator(byweekday=(MO, SA)) In addition, most of the constructors take an interval argument:: # tick on Mondays every second week loc = WeekdayLocator(byweekday=MO, interval=2) The rrule locator allows completely general date ticking:: # tick every 5th easter rule = rrulewrapper(YEARLY, byeaster=1, interval=5) loc = RRuleLocator(rule) The available date tick locators are: * `MicrosecondLocator`: Locate microseconds. * `SecondLocator`: Locate seconds. * `MinuteLocator`: Locate minutes. * `HourLocator`: Locate hours. * `DayLocator`: Locate specified days of the month. * `WeekdayLocator`: Locate days of the week, e.g., MO, TU. * `MonthLocator`: Locate months, e.g., 7 for July. * `YearLocator`: Locate years that are multiples of base. * `RRuleLocator`: Locate using a `rrulewrapper`. `rrulewrapper` is a simple wrapper around dateutil_'s `dateutil.rrule` which allow almost arbitrary date tick specifications. See :doc:`rrule example `. * `AutoDateLocator`: On autoscale, this class picks the best `DateLocator` (e.g., `RRuleLocator`) to set the view limits and the tick locations. If called with ``interval_multiples=True`` it will make ticks line up with sensible multiples of the tick intervals. For example, if the interval is 4 hours, it will pick hours 0, 4, 8, etc. as ticks. This behaviour is not guaranteed by default. .. _date-formatters: Date formatters --------------- The available date formatters are: * `AutoDateFormatter`: attempts to figure out the best format to use. This is most useful when used with the `AutoDateLocator`. * `ConciseDateFormatter`: also attempts to figure out the best format to use, and to make the format as compact as possible while still having complete date information. This is most useful when used with the `AutoDateLocator`. * `DateFormatter`: use `~datetime.datetime.strftime` format strings. N)rruleMOTUWETHFRSASUYEARLYMONTHLYWEEKLYDAILYHOURLYMINUTELYSECONDLY) relativedelta)_apicbooktickerunits)) datestr2numdate2numnum2date num2timedeltadrange set_epoch get_epoch DateFormatterConciseDateFormatterAutoDateFormatter DateLocator RRuleLocatorAutoDateLocator YearLocator MonthLocatorWeekdayLocator DayLocator HourLocator MinuteLocator SecondLocatorMicrosecondLocatorrrrrrrr r r r r rrrr MICROSECONDLYr DateConverterConciseDateConverter rrulewrapperctj|d}|dk(rtSt|tr1t j j|}|t|d|St|tjr|Std|d)z Generate `~datetime.tzinfo` from a string or return `~datetime.tzinfo`. If None, retrieve the preferred timezone from the rcParams dictionary. timezoneUTCz8 is not a valid timezone as parsed by dateutil.tz.gettz.z*tz must be string or tzinfo subclass, not .) mpl _val_or_rcr2 isinstancestrdateutiltzgettz ValueErrordatetimetzinfo TypeError)r9r=s V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/dates.py _get_tzinfor@s J 'B U{ "c""2& >t$334 4 "hoo& @aH IIg8@gN@g(@g@g>@gv@.Acday)zj Reset the Matplotlib date epoch so it can be set again. Only for use in tests and examples. N)_epochrAr?_reset_epoch_test_examplerHs FrAc*t td|ay)a Set the epoch (origin for dates) for datetime calculations. The default epoch is :rc:`date.epoch`. If microsecond accuracy is desired, the date being plotted needs to be within approximately 70 years of the epoch. Matplotlib internally represents dates as days since the epoch, so floating point dynamic range needs to be within a factor of 2^52. `~.dates.set_epoch` must be called before any dates are converted (i.e. near the import section) or a RuntimeError will be raised. See also :doc:`/gallery/ticks/date_precision_and_epochs`. Parameters ---------- epoch : str valid UTC date parsable by `numpy.datetime64` (do not include timezone). Nz.set_epoch must be called before dates plotted.)rF RuntimeError)epochs r?rr s0KLL FrAcBtjtdatS)z Get the epoch used by `.dates`. Returns ------- epoch : str String for the epoch (parsable by `numpy.datetime64`). z date.epoch)r4r5rFrGrAr?rr's^^FL 1F MrAc|jd}||z jd}tjtd}||z jtj}||jtjdz z }|t z }tjdjtj }|jtj }tj|||k(<|S)a< Convert `numpy.datetime64` or an `numpy.ndarray` of those types to Gregorian date as UTC float relative to the epoch (see `.get_epoch`). Roundoff is float64 precision. Practically: microseconds for dates between 290301 BC, 294241 AD, milliseconds for larger dates (see `numpy.datetime64`). z datetime64[s]ztimedelta64[ns]sgeANaT)astypenp datetime64rfloat64 SEC_PER_DAYint64nan)ddsecondsextrat0dtNaT_intd_ints r?_dt64_to_ordinalfr^6sxx(H \ ! !"3 4E y{C (B R-   +B%,,rzz "U **B k BmmE"))"((3G HHRXX E66Bu IrAc t|}tjttjt tj |tzdz}|tjdks|tjdk\rtd|d|dtd|j}|jtjjd }|j|}tj|d kDr]t |j d z d z}|d k(r+|jd t#j$dz}|S|j|}|S)ax Convert Gregorian float of the date, preserving hours, minutes, seconds and microseconds. Return value is a `.datetime`. The input date *x* is a float in ordinal days at UTC, and the output will be the specified `.datetime` object corresponding to that time in timezone *tz*, or if *tz* is ``None``, in the timezone specified in :rc:`timezone`. usz 0001-01-01z 10000-01-01z Date ordinal z converts to z (using epoch z;), but Matplotlib dates must be between year 0001 and 9999.r2r=c@Br) microsecondrC)seconds)r@rQrRr timedelta64introundMUSECONDS_PER_DAYr;tolistreplacer8r9r: astimezoneabsrer< timedelta)xr9r[mss r?_from_ordinalfrrNs@ RB -- $ ..RXXa*;&;<=t D EB BMM, ''2}1M+M===""++/889 9 B 8;;,,U3 4B r B vvay82>>B& '" , =*X-?-?-JJB I+B IrAO)otypesc t|tr,tjj ||}t |S|L|Dcgc],}t tjj ||.}}t j|St j|}|js|St t|Scc}w)a Convert a date string to a datenum using `dateutil.parser.parse`. Parameters ---------- d : str or sequence of str The dates to convert. default : datetime.datetime, optional The default date to use when fields are missing in *d*. default) r6r7r8parserparserrQasarraysize$_dateutil_parser_parse_np_vectorized)rWrwr[rNs r?rr{s!S __ " "1g " 6|  (////7/CDA::a= JJqMvvHrsh  a(rAc4t|jS)a Convert number of days to a `~datetime.timedelta` object. If *x* is a sequence, a sequence of `~datetime.timedelta` objects will be returned. Parameters ---------- x : float, sequence of floats Number of days. The fraction part represents hours, minutes, seconds. Returns ------- `datetime.timedelta` or list[`datetime.timedelta`] )$_ordinalf_to_timedelta_np_vectorizedrkrs r?rrs 0 2 9 9 ;;rAct|}t|}|jtz }tt j ||z |z }|||zz}||k\r ||z}|dz}t|}t j |||dzS)a Return a sequence of equally spaced Matplotlib dates. The dates start at *dstart* and reach up to, but not including *dend*. They are spaced by *delta*. Parameters ---------- dstart, dend : `~datetime.datetime` The date limits. delta : `datetime.timedelta` Spacing of the dates. Returns ------- `numpy.array` A list floats representing Matplotlib dates. rC)r total_secondsrTrhrQceillinspace)dstartdenddeltaf1f2stepnum dinterval_ends r?rrs( & B $B    ; .D bggrBw$&' (CS5[(M   q - B ;;r2sQw ''rAcd}tj|d|}|jddjdd}|jdd}d |zd z}|jd d }|S) Nz ([a-zA-Z]+)z}$\1$\\mathdefault{-z{-}:z{:} z\;z$\mathdefault{z}$z$\mathdefault{}$)resubrl)textpret_texts r? _wrap_in_texr'stAvva/6HU+33C?HU+H 8+d2H 3R8H OrAc,eZdZdZddddZddZdZy) rzi Format a tick (in days since the epoch) with a `~datetime.datetime.strftime` format string. Nusetexcht||_||_tj|d|_y)a Parameters ---------- fmt : str `~datetime.datetime.strftime` format string tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. usetex : bool, default: :rc:`text.usetex` To enable/disable the use of TeX's math mode for rendering the results of the formatter. text.usetexN)r@r9fmtr4r5_usetex)selfrr9rs r?__init__zDateFormatter.__init__=s(b/~~fm< rAct||jj|j}|jr t |S|SN)rr9strftimerrr)rrpposresults r?__call__zDateFormatter.__call__Ms7!TWW%..txx8'+|||F#??rAc$t||_yrr@r9rr9s r? set_tzinfozDateFormatter.set_tzinfoQs b/rAr)r)__name__ __module__ __qualname____doc__rrrrGrAr?rr7s =t= @"rArc<eZdZdZ d dddZd dZdZdZdZy) ra A `.Formatter` which attempts to figure out the best format to use for the date, and to make it as compact as possible, but still be complete. This is most useful when used with the `AutoDateLocator`:: >>> locator = AutoDateLocator() >>> formatter = ConciseDateFormatter(locator) Parameters ---------- locator : `.ticker.Locator` Locator that this axis is using. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone, passed to `.dates.num2date`. formats : list of 6 strings, optional Format strings for 6 levels of tick labelling: mostly years, months, days, hours, minutes, and seconds. Strings use the same format codes as `~datetime.datetime.strftime`. Default is ``['%Y', '%b', '%d', '%H:%M', '%H:%M', '%S.%f']`` zero_formats : list of 6 strings, optional Format strings for tick labels that are "zeros" for a given tick level. For instance, if most ticks are months, ticks around 1 Jan 2005 will be labeled "Dec", "2005", "Feb". The default is ``['', '%Y', '%b', '%b-%d', '%H:%M', '%H:%M']`` offset_formats : list of 6 strings, optional Format strings for the 6 levels that is applied to the "offset" string found on the right side of an x-axis, or top of a y-axis. Combined with the tick labels this should completely specify the date. The default is:: ['', '%Y', '%Y-%b', '%Y-%b-%d', '%Y-%b-%d', '%Y-%b-%d %H:%M'] show_offset : bool, default: True Whether to show the offset or not. usetex : bool, default: :rc:`text.usetex` To enable/disable the use of TeX's math mode for rendering the results of the formatter. Examples -------- See :doc:`/gallery/ticks/date_concise_formatter` .. plot:: import datetime import matplotlib.dates as mdates base = datetime.datetime(2005, 2, 1) dates = np.array([base + datetime.timedelta(hours=(2 * i)) for i in range(732)]) N = len(dates) np.random.seed(19680801) y = np.cumsum(np.random.randn(N)) fig, ax = plt.subplots(constrained_layout=True) locator = mdates.AutoDateLocator() formatter = mdates.ConciseDateFormatter(locator) ax.xaxis.set_major_locator(locator) ax.xaxis.set_major_formatter(formatter) ax.plot(dates, y) ax.set_title('Concise Date Formatter') Nrc||_||_d|_|r!t|dk7r t d||_n gd|_|r!t|dk7r t d||_nB|rdg|j ddz|_n'dg|j ddz|_d |j d <|r!t|dk7r t d ||_n gd |_d|_||_ tj|d |_ y)z Autoformat the date labels. The default format is used to form an initial string, and then redundant elements are removed. %Yz=formats argument must be a list of 6 format strings (or None))rz%bz%d%H:%Mrz%S.%fzBzero_formats argument must be a list of 6 format strings (or None)rNz%b-%dzDoffset_formats argument must be a list of 6 format strings (or None))rrz%Y-%b%Y-%b-%drz%Y-%b-%d %H:%Mr) _locator_tz defaultfmtlenr;formats zero_formatsoffset_formats offset_string show_offsetr4r5r)rlocatorr9rrrrrs r?rzConciseDateFormatter.__init__s    7|q  ">??"DLDL < A% ">?? ,D  !#t||CR'8 8D "$t||CR'8 8D #*D  a >"a' ">??"0D #5D   &~~fm< rAcnt|j|j|j}|||S)Nr)r)rrrr)rrpr formatters r?rzConciseDateFormatter.__call__s,!$//488)-7 $$rAc|Dcgc]}t||j}}tj|Dcgc]}|j ddc}}|j }|j }|j}|j} tdddD]U} tj|dd| f} t| dkDr!| dkrtj| dk(rd} n | dk(sTd} Wgd } d gt|z} tt|D]k} dkr||| | | k(r|| }n9|| }n3||j||jcxk(rdk(r nn|| }n|| }||j|| |<m dk\rRt!d | Dd }|rz4ConciseDateFormatter.format_ticks..s,IqQ#ahhsm,,Is 7+7rvr3)xaxisyaxis)rrrQarray timetuplerrrrrangeuniqueranysecondrerminrraxisr get_invertedrrr)rvaluesvalue tickdatetimetdttickdatefmtszerofmts offsetfmtsrlevelrzerovalslabelsnnrtrailing_zerosls r? format_ticksz!ConciseDateFormatter.format_tickssBHI4884I I88LISS]]_Ra0IJ||$$(( && 1b"% EYYx512F6{Q19! !4"'K! )H %H & 8BqyB<&(5/9"5/Cu+C!$++|B/?/K/K"5/Cu+C%b)2237F2J 8( A: IfINF ,NBfRj(%+BZ0@.%A%H%H%Mr N  ""MM&&//3EE **779%1!_%=%=j>O%P"%1"%5%>%>z%?P%Q"||%1$2D2D%E"!#D  <<-34LO4 4McJI\5sKK /Kc|jSr)rrs r? get_offsetzConciseDateFormatter.get_offset/s!!!rAcNt||jjdS)Nrz%Y-%m-%d %H:%M:%S)rrr)rrs r?format_data_shortz&ConciseDateFormatter.format_data_short2s$((+445HIIrA)NNNNTr) rrrrrrrrrrGrAr?rrUs8DLGK048=@D8=t% Rh"JrArc,eZdZdZddddZdZddZy) r a A `.Formatter` which attempts to figure out the best format to use. This is most useful when used with the `AutoDateLocator`. `.AutoDateFormatter` has a ``.scale`` dictionary that maps tick scales (the interval in days between one major tick) to format strings; this dictionary defaults to :: self.scaled = { DAYS_PER_YEAR: rcParams['date.autoformatter.year'], DAYS_PER_MONTH: rcParams['date.autoformatter.month'], 1: rcParams['date.autoformatter.day'], 1 / HOURS_PER_DAY: rcParams['date.autoformatter.hour'], 1 / MINUTES_PER_DAY: rcParams['date.autoformatter.minute'], 1 / SEC_PER_DAY: rcParams['date.autoformatter.second'], 1 / MUSECONDS_PER_DAY: rcParams['date.autoformatter.microsecond'], } The formatter uses the format string corresponding to the lowest key in the dictionary that is greater or equal to the current scale. Dictionary entries can be customized:: locator = AutoDateLocator() formatter = AutoDateFormatter(locator) formatter.scaled[1/(24*60)] = '%M:%S' # only show min and sec Custom callables can also be used instead of format strings. The following example shows how to use a custom format function to strip trailing zeros from decimal seconds and adds the date to the first ticklabel:: def my_format_function(x, pos=None): x = matplotlib.dates.num2date(x) if pos == 0: fmt = '%D %H:%M:%S.%f' else: fmt = '%H:%M:%S.%f' label = x.strftime(fmt) label = label.rstrip("0") label = label.rstrip(".") return label formatter.scaled[1/(24*60)] = my_format_function NrcV||_||_||_t|j||_t j }t j|d|_t|dt|dd|ddtz |ddtz |ddtz |ddtz |d i|_y ) a. Autoformat the date labels. Parameters ---------- locator : `.ticker.Locator` Locator that this axis is using. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. defaultfmt : str The default format to use if none of the values in ``self.scaled`` are greater than the unit returned by ``locator._get_unit()``. usetex : bool, default: :rc:`text.usetex` To enable/disable the use of TeX's math mode for rendering the results of the formatter. If any entries in ``self.scaled`` are set as functions, then it is up to the customized function to enable or disable TeX's math mode itself. rzdate.autoformatter.yearzdate.autoformatter.monthrCzdate.autoformatter.dayzdate.autoformatter.hourzdate.autoformatter.minutezdate.autoformatter.secondzdate.autoformatter.microsecondN)rrrr _formatterr4rcParamsr5r DAYS_PER_YEARDAYS_PER_MONTH HOURS_PER_DAYMINUTES_PER_DAYrTrjscaled)rrr9rrrs r?rzAutoDateFormatter.__init__ns.  $'<<<~~fm< 8$=> H%?@ x01 x(AB  *E!F OX&AB ! !8,L#M  rAc||_yr)r)rrs r? _set_locatorzAutoDateFormatter._set_locators  rAc t|jjt fdt |j jD|j}t|tr;t||j|j|_|j||}|St|r |||}|St!d|d#t$rdYwxYw)NrCc32K|]\}}|k\r|ywrrG)rscalerlocator_unit_scales r?rz-AutoDateFormatter.__call__..s%4JE3 224srzUnexpected type passed to r3)floatr _get_unitAttributeErrornextsortedritemsrr6r7rrrrcallabler>)rrprrrr s @r?rzAutoDateFormatter.__call__s #!&t}}'>'>'@!A 4&1B1B1D*E4??$ c3 +C$,,ODO__Q,F  c]C[F 8BC C #!"  #s#C C$#C$)Nz%Y-%m-%dr)rrrrrrrrGrAr?r r 6s *n% % N rAr c>eZdZdZd dZdZdZdZd dZdZ d Z y) r/zd A simple wrapper around a `dateutil.rrule` allowing flexible date tick specifications. Nc @||d<||_|jdi|y)a Parameters ---------- freq : {YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY} Tick frequency. These constants are defined in `dateutil.rrule`, but they are accessible from `matplotlib.dates` as well. tzinfo : `datetime.tzinfo`, optional Time zone information. The default is None. **kwargs Additional keyword arguments are passed to the `dateutil.rrule`. freqNrG) _base_tzinfo _update_rrule)rrr=kwargss r?rzrrulewrapper.__init__s(v"$V$rAc r|jj||jdi|jy)z'Set parameters for an existing wrapper.NrG) _constructupdater)rrs r?setzrrulewrapper.sets+ v&-T__-rAc |j}d|vrF|d}|j5| |j}n|j|}|jd|d<d|vrE|d}|j4||j|}n t d|jd|d<|j |_||_tdi|j |_ y)Ndtstartrauntilz$^^F%008G$+OO4O$@y! f 7OE||'%!,,V4E$&CDD#(--t-"<w ++- .doo. rAcdt|dr|j|dS|j|S)NlocalizeT)is_dstra)hasattrr#rl)rr[r=s r?_attach_tzinfozrrulewrapper._attach_tzinfos0 6: &??2d?3 3zzz((rAcjSfdfd|sfd}nfd}tj|S)z>Decorator function that allows rrule methods to handle tzinfo.ct|tjrQ|jE|jjur|j j}|j dS|S)Nra)r6r<r=r rmrl)argrs r? normalize_argz9rrulewrapper._aware_return_wrapper..normalize_argsT#x001cjj6L::T\\1..6C{{${//JrActfd|D}|jDcic]\}}||}}}||fScc}}w)Nc3.K|] }|ywrrG)rr)r*s r?rzMrrulewrapper._aware_return_wrapper..normalize_args..s<s+.normalize_argssJ.inner_func s9-dF; f''**2t||<.inner_funcsG-dF; f((HKL"++B =LLLs#A)r  functoolswraps)rr3 returns_listr4r*r0s`` @@r?_aware_return_wrapperz"rrulewrapper._aware_return_wrappersF << H   =  M "yq!*--rAc||jvr|j|St|j|}|dvr|j|S|dvr|j|dS|S)N>afterbefore>xafterbetweenxbeforeT)r9)__dict__rr!r:)rnamer3s r? __getattr__zrrulewrapper.__getattr__sk 4== ==& & DKK & & &--a0 0 5 5--ad-C CHrAc:|jj|yr)rAr)rstates r? __setstate__zrrulewrapper.__setstate__"s U#rAr)F) rrrrrrrr&r:rCrFrGrAr?r/r/s+%". />)$.L $rAr/cHeZdZdZddddZd dZdZdZdZd Z d Z d Z y) r!z Determines the tick locations when plotting dates. This class is subclassed by other Locators and is not meant to be used on its own. r)byhourbyminutebysecondNc$t||_y)z Parameters ---------- tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. Nrrs r?rzDateLocator.__init__/sb/rAc$t||_y)z Set timezone info. Parameters ---------- tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. Nrrs r?rzDateLocator.set_tzinfo8sb/rAc|jj\}}||kDr||}}t||jt||jfS)z/Convert axis data interval to datetime objects.)rget_data_intervalrr9rdmindmaxs r? datalim_to_dtzDateLocator.datalim_to_dtCsIYY002 d $;t$Ddgg&tww(???rAc|jj\}}||kDr||}}t||jt||jfS)z.Convert the view interval to datetime objects.)rget_view_intervalrr9rvminvmaxs r? viewlim_to_dtzDateLocator.viewlim_to_dtKsIYY002 d $;t$Ddgg&tww(???rAcy)zj Return how many days a unit of the locator is; used for intelligent autoscaling. rCrGrs r?r zDateLocator._get_unitRs rAcy)z; Return the number of units for each tick. rCrGrs r? _get_intervalzDateLocator._get_intervalYsrAc~tj|rtj|s@ttjdddttjdddfS||kr||}}|j }|j }t||z dkr|d|z|zz}|d|z|zz }||fS)z Given the proposed upper and lower extent, adjust the range if it is too close to being singular (i.e. a range of ~0). rBrCrgư>)rQisfiniterr<dater r[rn)rrVrWunitintervals r? nonsingularzDateLocator.nonsingular_s {{4  D(9X]]4A67X]]4A679 9 $;t$D~~%%' td{ d " AHx' 'D AHx' 'DTzrAr) rrrrhms0drrrRrXr r[rarGrAr?r!r!&s: aQ 7E" "@@ rAr!cNeZdZdfd ZdZdZdZdZedZ dZ xZ S) r"c2t||||_yr)superrrule)ror9 __class__s r?rzRRuleLocator.__init__us  rAcp |j\}}|j||S#t$rgcYSwxYwrrXr; tick_valuesrOs r?rzRRuleLocator.__call__yD ++-JD$d++ I  ' 55c|j||\}}|jj||d}t|dk(r t ||gS|j t |S)NTr) _create_rrulerfr?rrraise_if_exceeds)rrVrWstartstopdatess r?rkzRRuleLocator.tick_valuess_((t4 t !!%t4 u:?T4L) )$$Xe_55rAc t||} ||z } ||z}|j j|| ||fS#ttf$r7tjddddddtjj }YlwxYw#ttf$r7tjddddddtjj }YwxYw) NrCrra' ;rr)rr; OverflowErrorr<r1utcrfr)rrVrWrrqrrs r?rozRRuleLocator._create_rrulesdD) D5LE  C%->-B-BDE DM* C$$T2r2r2,4,=,=,A,ACD Cs":BAB?BAC C cd|jjj}|j|Sr)rfr!_freqget_unit_generic)rrs r?r zRRuleLocator._get_units(yy%%$$T**rAc|tk(rtS|tk(rtS|tk(rt S|t k(ry|tk(r dtz S|tk(r dtz S|tk(r dtz Sy)N?r) r rr rr DAYS_PER_WEEKrrrrrrrT)rs r?rzRRuleLocator.get_unit_genericsp 6> W_! ! V^ U] V^& & X ( ( X $ $rAcB|jjjSr)rfr! _intervalrs r?r[zRRuleLocator._get_intervalsyy)))rAr) rrrrrrkror  staticmethodrr[ __classcell__rhs@r?r"r"rs5,60+ &*rAr"cFeZdZdZ dfd ZdZdZdZdZdZ xZ S) r#a On autoscale, this class picks the best `DateLocator` to set the view limits and the tick locations. Attributes ---------- intervald : dict Mapping of tick frequencies to multiples allowed for that ticking. The default is :: self.intervald = { YEARLY : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500, 1000, 2000, 4000, 5000, 10000], MONTHLY : [1, 2, 3, 4, 6], DAILY : [1, 2, 3, 7, 14, 21], HOURLY : [1, 2, 3, 4, 6, 12], MINUTELY: [1, 5, 10, 15, 30], SECONDLY: [1, 5, 10, 15, 30], MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000], } where the keys are defined in `dateutil.rrule`. The interval is used to specify multiples that are appropriate for the frequency of ticking. For instance, every 7 days is sensible for daily ticks, but for minutes/seconds, 15 or 30 make sense. When customizing, you should only modify the values for the existing keys. You should not add or delete entries. Example for forcing ticks every 3 hours:: locator = AutoDateLocator() locator.intervald[HOURLY] = [3] # only show every 3 hours ct||t|_ttt t tttg|_ ||_ tdtdt dt dtdtdtdi|_ | |jj|||_tgdtgdt gdt gd tgd tgd tgd i|_|rgd |j$t <dt'd dt'd dt'ddt'ddt'dddg|_y#t$r(tj!|j||_ YwxYw)a Parameters ---------- tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. minticks : int The minimum number of ticks desired; controls whether ticks occur yearly, monthly, etc. maxticks : int The maximum number of ticks desired; controls the interval between ticks (ticking every other, every 3, etc.). For fine-grained control, this can be a dictionary mapping individual rrule frequency constants (YEARLY, MONTHLY, etc.) to their own maximum number of ticks. This can be used to keep the number of ticks appropriate to the format chosen in `AutoDateFormatter`. Any frequency not specified in this dictionary is given a default value. interval_multiples : bool, default: True Whether ticks should be chosen to be multiple of the interval, locking them to 'nicer' locations. For example, this will force the ticks to be at hours 0, 6, 12, 18 when hourly ticking is done at 6 hour intervals. r rvN)rCrr rc(2dii')rCrrrr)rCrr)rCrrrrrv)rCrr)rCrrrrcrrrrrrrri NiPii@ i rd)rCrrrrrC r<)rerr r~r rrrrr,_freqsminticksmaxticksrr>dictfromkeysinterval_multiples intervaldr _byranges)rr9rrrrhs r?rzAutoDateLocator.__init__s:2 B wvx0   Wb%VR!2x]AG   E $$X. #5 6 o * ) ( ( %  %5DNN5 !a eArl2,a eArlDJ1 E!% dkk8 D  EsD;;.E,+E,cZ|j\}}|j||}|Sr)rX get_locator)rrPrQrs r?rzAutoDateLocator.__call__%s.'') d""4.yrAcF|j||j||Sr)rrkrUs r?rkzAutoDateLocator.tick_values+s"d+77dCCrAc*tj|rtj|s@ttjdddttjdddfS||kr||}}||k(r|t dzz }|t dzz}||fS)NrBrCr)rQr]rr<r^rrUs r?razAutoDateLocator.nonsingular.s{{4  D(9X]]4A67X]]4A679 9 $;t$D 4<-!++D-!++DTzrAcx|jtfvr dtz Stj |jSNr)r~r,rjr"rrs r?r zAutoDateLocator._get_unit<s1 ::- ()) )00< ?' NA{cT]]"# !NN40 L(dmmD&9A&=>> L//DEM&&?@HjKLDJ~~a T%<%<"nnQ/ ( ; '2~'("g !Q&4 "nnQ/ K' NH FN 7 7!(tww7G q !DL AAw FHh h)-T)0Z(.*2 4E #5TWW5G(dgg>G~(X_""//8{m< #rA)NrNT) rrrrrrrkrar rrrs@r?r#r#s3%N6:$(=J~ D = brAr#c*eZdZdZdfd ZdZxZS)r$z Make ticks on a given day of each year that is a multiple of base. Examples:: # Tick every year on Jan 1st locator = YearLocator() # Tick every 5 years on July 4th locator = YearLocator(5, month=7, day=4) cttf|||d|j}t|||t j |d|_y)a Parameters ---------- base : int, default: 1 Mark ticks every *base* years. month : int, default: 1 The month on which to place the ticks, starting from 1. Default is January. day : int, default: 1 The day on which to place the ticks. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. )r`rrrrN)r/r rbrerr _Edge_integerbase)rrmonthdayr9rfrhs r?rzYearLocator.__init__sOF:T5'*:.2jj: "%((q1 rAc"t|jj|j|jjzd}t |jj |j|jjzd}|jj}||jdd|jdddddd}|jd i|}|j|}|jj||||fS) NrCrurrr)yearrrhourminuter)rrzrG) maxrlerrrgerfrgetrlr) rrVrWyminymaxcrlrqrrs r?rozYearLocator._create_rrules499<< *TYY^^;Q?499<< *TYY^^;TB II EE)Q/%% a0Q8  'w'}}$}' e4 0d{rA)rCrCrCN)rrrrrrorrs@r?r$r$s 2&rAr$c$eZdZdZdfd ZxZS)r%zB Make ticks on occurrences of each month, e.g., 1, 3, 12. c| tdd}ttf|||d|j}t|||y)a` Parameters ---------- bymonth : int or list of int, default: all months Ticks will be placed on every month in *bymonth*. Default is ``range(1, 13)``, i.e. every month. bymonthday : int, default: 1 The day on which to place the ticks. interval : int, default: 1 The interval between each iteration. For example, if ``interval=2``, mark every second occurrence. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. NrCr)rrr`r)rr/r rbrer)rrrr`r9rfrhs r?rzMonthLocator.__init__sK ?ArlGG=W%-=15= "%rA)NrCrCNrrrrrrrs@r?r%r%s&&rAr%c$eZdZdZdfd ZxZS)r&z4 Make ticks on occurrences of each weekday. cbttf||d|j}t|||y)a Parameters ---------- byweekday : int or list of int, default: all days Ticks will be placed on every weekday in *byweekday*. Default is every day. Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA, SU, the constants from :mod:`dateutil.rrule`, which have been imported into the :mod:`matplotlib.dates` namespace. interval : int, default: 1 The interval between each iteration. For example, if ``interval=2``, mark every second occurrence. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. ) byweekdayr`rN)r/rrbrer)rrr`r9rfrhs r?rzWeekdayLocator.__init__s9"E=Y%-=15= "%rA)rCrCNrrs@r?r&r&s&&rAr&c$eZdZdZdfd ZxZS)r'zZ Make ticks on occurrences of each day of the month. For example, 1, 15, 30. c|t|k7s|dkr td| tdd}ttf||d|j }t |||y)a# Parameters ---------- bymonthday : int or list of int, default: all days Ticks will be placed on every day in *bymonthday*. Default is ``bymonthday=range(1, 32)``, i.e., every day of the month. interval : int, default: 1 The interval between each iteration. For example, if ``interval=2``, mark every second occurrence. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. rCz*interval must be an integer greater than 0Nr)rr`r)rhr;rr/rrbrer)rrr`r9rfrhs r?rzDayLocator.__init__sh s8} $1 IJ J  q"JE=j%-=15= "%rANrCNrrs@r?r'r's&&rAr'c$eZdZdZdfd ZxZS)r(z1 Make ticks on occurrences of each hour. cj| td}tt||dd}t|||y)a  Parameters ---------- byhour : int or list of int, default: all hours Ticks will be placed on every hour in *byhour*. Default is ``byhour=range(24)``, i.e., every hour. interval : int, default: 1 The interval between each iteration. For example, if ``interval=2``, mark every second occurrence. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. Nrr)rHr`rIrJr)rr/rrer)rrHr`r9rfrhs r?rzHourLocator.__init__/s: >2YFF6H%&4 "%rArrrs@r?r(r(+&&rAr(c$eZdZdZdfd ZxZS)r)z3 Make ticks on occurrences of each minute. ch| td}tt||d}t|||y)a Parameters ---------- byminute : int or list of int, default: all minutes Ticks will be placed on every minute in *byminute*. Default is ``byminute=range(60)``, i.e., every minute. interval : int, default: 1 The interval between each iteration. For example, if ``interval=2``, mark every second occurrence. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. Nrr)rIr`rJr)rr/rrer)rrIr`r9rfrhs r?rzMinuteLocator.__init__Hs9  RyHHx(%&( "%rArrrs@r?r)r)DrrAr)c$eZdZdZdfd ZxZS)r*z3 Make ticks on occurrences of each second. cf| td}tt||}t|||y)a Parameters ---------- bysecond : int or list of int, default: all seconds Ticks will be placed on every second in *bysecond*. Default is ``bysecond = range(60)``, i.e., every second. interval : int, default: 1 The interval between each iteration. For example, if ``interval=2``, mark every second occurrence. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. Nr)rJr`r)rr/rrer)rrJr`r9rfrhs r?rzSecondLocator.__init__as4  RyHHx(K "%rArrrs@r?r*r*]s&&rAr*cFeZdZdZdfd ZfdZdZdZdZdZ xZ S) r+a9 Make ticks on regular intervals of one or more microsecond(s). .. note:: By default, Matplotlib uses a floating point representation of time in days since the epoch, so plotting data with microsecond time resolution does not work well for dates that are far (about 70 years) from the epoch (check with `~.dates.get_epoch`). If you want sub-microsecond resolution time plots, it is strongly recommended to use floating point seconds, not datetime-like time representation. If you really must use datetime.datetime() or similar and still need microsecond precision, change the time origin via `.dates.set_epoch` to something closer to the dates being plotted. See :doc:`/gallery/ticks/date_precision_and_epochs`. cht||||_tj||_y)aW Parameters ---------- interval : int, default: 1 The interval between each iteration. For example, if ``interval=2``, mark every second occurrence. tz : str or `~datetime.tzinfo`, default: :rc:`timezone` Ticks timezone. If a string, *tz* is passed to `dateutil.tz`. rN)rerrrMultipleLocator_wrapped_locator)rr`r9rhs r?rzMicrosecondLocator.__init__s/ B! & 6 6x @rAcX|jj|t||Sr)rrre)rrrhs r?rzMicrosecondLocator.set_axiss' &&t,w%%rAcp |j\}}|j||S#t$rgcYSwxYwrrjrOs r?rzMicrosecondLocator.__call__rlrmct||f\}}tj|}||z }||z }|tz}|tz}|jj ||}|tz |z}|Sr)rrQrrjrrk)rrVrWnminnmaxrZtickss r?rkzMicrosecondLocator.tick_valuessvtTl+ d XXd^byby !! !!%%11$=))B. rAcdtz Sr)rjrs r?r zMicrosecondLocator._get_units%%%rAc|jSr)rrs r?r[z MicrosecondLocator._get_intervals ~~rA)rCN) rrrrrrrrkr r[rrs@r?r+r+us'* A&, &rAr+cNeZdZdZddfd ZdZedZedZxZ S)r-z Converter for `datetime.date` and `datetime.datetime` data, or for date/time data represented as it would be converted by `date2num`. The 'unit' tag for such data is None or a `~datetime.tzinfo` instance. Trc0||_t| yr)_interval_multiplesrer)rrrhs r?rzDateConverter.__init__s#5  rAc|}t||j}t||}tjddd}tjddd}t j ||d||fS)z Return the `~matplotlib.units.AxisInfo` for *unit*. *unit* is a `~datetime.tzinfo` instance or None. The *axis* argument is required but not used. r9rrrBrCrrmajlocmajfmtlabeldefault_limits)r#rr r<r^rAxisInforr_rr9rrdatemindatemaxs r?axisinfozDateConverter.axisinfosp B484L4LN"6b1--a+--a+~~VF".5w-?A ArAct|S)z If *value* is not already a number or sequence of numbers, convert it with `date2num`. The *unit* and *axis* arguments are not used. )r)rr_rs r?convertzDateConverter.convertsrAct|tjr|j} t j |} |jS#t tf$rYwxYw#t$rYywxYw)zh Return the `~datetime.tzinfo` instance of *x* or of its first element, or None N) r6rQndarrayravelr_safe_first_finiter> StopIterationr=r )rprs r? default_unitszDateConverter.default_unitsso a $ A ((+A 88O =)       s#A A#A A # A/.A/) rrrrrrrrrrrs@r?r-r-s@.2A$rAr-c0eZdZ dddfd ZdZxZS)r.Trch||_||_||_||_||_t |yr)_formats _zero_formats_offset_formats _show_offsetrrer)rrrrrrrhs r?rzConciseDateConverter.__init__s5 )-'#5  rAc8|}t||j}t|||j|j|j |j }tjddd}tjddd}tj||d||fS)Nr)r9rrrrrBrCrrr) r#rrrrrrr<r^rrrs r?rzConciseDateConverter.axisinfos  B484L4LN%fT]]373E3E595I5I262C2CE--a+--a+~~VF".5w-?A ArA)NNNT)rrrrrrrs@r?r.r.s HL!9= ArAr.c2eZdZdZedZdZdZdZy)_SwitchableDateConverterz Helper converter-like object that generates and dispatches to temporary ConciseDateConverter or DateConverter instances based on :rc:`date.converter` and :rc:`date.interval_multiples`. c|ttdtjd}tjd}||S)N)conciseautozdate.converterzdate.interval_multiplesr)r.r-r4r) converter_clsrs r?_get_converterz'_SwitchableDateConverter._get_convertersA,]D -.0 !\\*CD0BCCrAcB|jj|i|Sr)rrrr.rs r?rz!_SwitchableDateConverter.axisinfo#s#-t""$--t>v>>rAcB|jj|i|Sr)rrrs r?rz&_SwitchableDateConverter.default_units&s#2t""$22DCFCCrAcB|jj|i|Sr)rrrs r?rz _SwitchableDateConverter.convert)s#,t""$,,d=f==rAN) rrrrrrrrrrGrAr?rrs- DD?D>rArr)lrr<r7loggingrdateutil.rrulerrrrrrr r r r r rrrrdateutil.relativedeltardateutil.parserr8 dateutil.tznumpyrQ matplotlibr4rrrr__all__ getLoggerr_logr1r|r2r@r  toordinal EPOCH_OFFSETr,rr SEC_PER_MINrrrrr SEC_PER_HOURrT SEC_PER_WEEKrjMONDAYTUESDAY WEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAYWEEKDAYSrFrHrrr^rr vectorizerrxryr|rrrrrrr Formatterrrr r/Locatorr!r"r#r$r%r&r'r(r)r*r+ConversionInterfacer-r.rregistryrRr^rGrAr?r=sm^ &&&&&111 Dw"J(&X&&tQ2<<>? 1      .\) ]* ]* +%BBBB >Hfh GY&(F K : 0$P ,r||N3G'3r||HOO4I4I'J$A41#h8<(4r||((6$<&&(R  "F$$"<^J6++^JBt((tnv$v$rI&..IXI*;I*XfkfR/,/d&<&6&\&6&&8&,&2&L&2&L&0DDN:E--:zA=A6>>8r}} NN8==! NN8$$%rA