
    h                    Z   S r SSKrSSKrSSKrSSKrSSKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJr  SSKJr  SSKrSSKrSSKrSSKrSSKJrJrJ r J!r!  Sr"\RF                  " \$5      r%\RL                  RN                  r(SCS jr)\*" \R                  " SS	S	5      RW                  5       5      r,\S	-   r-S
r.Sr/Sr0Sr1Sr2Sr3Sr4\/\.-  r5\0\/-  r6\6\.-  r7\7\2-  r8S\7-  r9\\\	\
\\\4u  r:r;r<r=r>r?r@\:\;\<\=\>\?\@4rASqBS rCS rDS rES rFSCS jrG\R                  " \GSS9rI\R                  " \R                  R                  5      rLSCS jrMS rNSCS jrO\R                  " S SS9rPS rQS rRS rS " S S \ R                  5      rU " S! S"\ R                  5      rV " S# S$\ R                  5      rW " S% S&5      rX " S' S(\ R                  5      rZ " S) S*\Z5      r[ " S+ S,\Z5      r\ " S- S.\[5      r] " S/ S0\[5      r^ " S1 S2\[5      r_ " S3 S4\[5      r` " S5 S6\[5      ra " S7 S8\[5      rb " S9 S:\[5      rc " S; S<\Z5      rd " S= S>\!R                  5      rf " S? S@\f5      rg " SA SB5      rh\h" 5       =\!R                  \R                  '   =\!R                  \R                  '   \!R                  \R                  '   g)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 </gallery/ticks/date_demo_rrule>`.

* `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)rruleMOTUWETHFRSASUYEARLYMONTHLYWEEKLYDAILYHOURLYMINUTELYSECONDLY)relativedelta)_apicbooktickerunits))datestr2numdate2numnum2datenum2timedeltadrange	set_epoch	get_epochDateFormatterConciseDateFormatterAutoDateFormatterDateLocatorRRuleLocatorAutoDateLocatorYearLocatorMonthLocatorWeekdayLocator
DayLocatorHourLocatorMinuteLocatorSecondLocatorMicrosecondLocatorr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   MICROSECONDLYr   DateConverterConciseDateConverterrrulewrapperc                 8   [         R                  " U S5      n U S:X  a  [        $ [        U [        5      (       a2  [
        R                  R                  U 5      nUc  [        U  S35      eU$ [        U [        R                  5      (       a  U $ [        SU < S35      e)z
Generate `~datetime.tzinfo` from a string or return `~datetime.tzinfo`.
If None, retrieve the preferred timezone from the rcParams dictionary.
timezoneUTCz8 is not a valid timezone as parsed by dateutil.tz.gettz.z*tz must be string or tzinfo subclass, not .)mpl
_val_or_rcr2   
isinstancestrdateutiltzgettz
ValueErrordatetimetzinfo	TypeError)r9   r=   s     B/var/www/html/env/lib/python3.13/site-packages/matplotlib/dates.py_get_tzinfor@      s    
 
J	'B	U{
"c""2&>t $3 3 4 4"hoo&&	
@aH
II         g      8@g      N@g      (@g      @g      >@g     v@    .Ac                      Sq g)z^
Reset the Matplotlib date epoch so it can be set again.

Only for use in tests and examples.
N)_epoch rA   r?   _reset_epoch_test_examplerH      s	     FrA   c                 ,    [         b  [        S5      eU q g)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?   r   r   
  s    0 KLLFrA   c                  D    [         R                  " [        S5      q[        $ )zy
Get the epoch used by `.dates`.

Returns
-------
epoch : str
    String for the epoch (parsable by `numpy.datetime64`).
z
date.epoch)r4   r5   rF   rG   rA   r?   r   r   '  s     ^^FL1FMrA   c                    U R                  S5      nX-
  R                  S5      n[        R                  " [        5       S5      nX-
  R                  [        R                  5      nXBR                  [        R                  5      S-  -  nU[
        -  n[        R                  " S5      R                  [        R                  5      nU R                  [        R                  5      n[        R                  XFU:H  '   U$ )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]ztimedelta64[ns]sg    eANaT)astypenp
datetime64r   float64SEC_PER_DAYint64nan)ddsecondsextrat0dtNaT_intd_ints          r?   _dt64_to_ordinalfr^   6  s     xx(H\!!"34E	y{C	(B
-		

	+B,,rzz
"U
**B	k	BmmE"))"((3GHHRXXE66BIrA   c           	         [        U5      n[        R                  " [        5       5      [        R                  " [        [        R                  " U [        -  5      5      S5      -   nU[        R                  " S5      :  d  U[        R                  " S5      :  a  [        SU  SU S[        5        S35      eUR                  5       nUR                  [        R                  R                  S5      S	9nUR                  U5      n[        R                  " U 5      S
:  aV  [        UR                   S-  5      S-  nUS:X  a&  UR                  SS9["        R$                  " SS9-   nU$ UR                  US9nU$ )a\  
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.r2   r=   c     @B r   )microsecondrC   )seconds)r@   rQ   rR   r   timedelta64introundMUSECONDS_PER_DAYr;   tolistreplacer8   r9   r:   
astimezoneabsre   r<   	timedelta)xr9   r[   mss       r?   _from_ordinalfrr   N  s@    
RB
--	
$
..RXXa*;&;<=t
DEB	BMM,''2}1M+M== =""++ /88 9 	9 
B 
8;;,,U3	4B	r	B	vvay8 2>>B&'",=*X-?-?-JJB I +BIrA   O)otypesc           
         [        U [        5      (       a(  [        R                  R	                  XS9n[        U5      $ UbL  U  Vs/ s H)  n[        [        R                  R	                  X1S95      PM+     n n[        R                  " U 5      $ [        R                  " U 5      n U R                  (       d  U $ [        [        U 5      5      $ s  snf )z
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)
r6   r7   r8   parserparser   rQ   asarraysize$_dateutil_parser_parse_np_vectorized)rW   rw   r[   rN   s       r?   r   r   {  s     !S__""1"6|Q (/////CD  ::a= JJqMvvH<Q?@@s   0C
c                    [         R                  " U 5      n [        R                  " U 5      nU(       d  U /n [        R                  R                  U 5      n[        R                  R                  U 5      n[        R                  " U 5      n [        R                  " U R                  [        R                  5      (       d~  U R                  (       d  U $ [        U S   SS5      nUbG  U  Vs/ s H$  oUR                  [        5      R                  SS9PM&     n n[        R                  " U 5      n U R!                  S5      n U(       a  [        R                  R#                  XS9OU n [%        U 5      n U(       a  U $ U S   $ s  snf )a#  
Convert datetime objects to Matplotlib dates.

Parameters
----------
d : `datetime.datetime` or `numpy.datetime64` or sequences of these

Returns
-------
float or sequence of floats
    Number of days since the epoch.  See `.get_epoch` for the
    epoch, which can be changed by :rc:`date.epoch` or `.set_epoch`.  If
    the epoch is "1970-01-01T00:00:00" (default) then noon Jan 1 1970
    ("1970-01-01T12:00:00") returns 0.5.

Notes
-----
The Gregorian calendar is assumed; this is not universal practice.
For details see the module docstring.
r   r=   Nra   zdatetime64[us])mask)r   _unpack_to_numpyrQ   iterablema	is_maskedgetmaskrz   
issubdtypedtyperR   r{   getattrrm   r2   rl   rP   masked_arrayr^   )rW   r   maskedr~   tzir[   s         r?   r   r     s   , 	q!A {{1~HCUU__QF55==D


1A =="--00vvHadHd+?CDE1Rs#++4+81AE

1AHH%&,21(A!A1"ad" Fs   )+E<c                 J    [        U5      n[        X5      R                  5       $ )a  
Convert Matplotlib dates to `~datetime.datetime` objects.

Parameters
----------
x : float or sequence of floats
    Number of days (fraction part represents hours, minutes, seconds)
    since the epoch.  See `.get_epoch` for the
    epoch, which can be changed by :rc:`date.epoch` or `.set_epoch`.
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
    Timezone of *x*. If a string, *tz* is passed to `dateutil.tz`.

Returns
-------
`~datetime.datetime` or sequence of `~datetime.datetime`
    Dates are returned in timezone *tz*.

    If *x* is a sequence, a sequence of `~datetime.datetime` objects will
    be returned.

Notes
-----
The Gregorian calendar is assumed; this is not universal practice.
For details, see the module docstring.
)r@   _from_ordinalf_np_vectorizedrk   )rp   r9   s     r?   r   r     s!    4 
RB'.5577rA   c                 *    [         R                  " U S9$ )N)days)r<   ro   rp   s    r?   <lambda>r     s    h  a(rA   c                 4    [        U 5      R                  5       $ )aS  
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_vectorizedrk   r   s    r?   r   r     s      0299;;rA   c                    [        U 5      n[        U5      nUR                  5       [        -  n[        [        R
                  " XC-
  U-  5      5      nXU-  -   nXq:  a	  Xr-  nUS-  n[        U5      n[        R                  " X4US-   5      $ )as  
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_secondsrT   rh   rQ   ceillinspace)dstartdenddeltaf1f2stepnumdinterval_ends           r?   r   r     s    ( 
&	B	$B ;.D bggrw$&'
(C 5[(M  	q	-	 B;;rsQw''rA   c                     Sn[         R                  " USU 5      nUR                  SS5      R                  SS5      nUR                  SS5      nS	U-   S
-   nUR                  SS5      nU$ )Nz([a-zA-Z]+)z}$\1$\\mathdefault{-z{-}:z{:} z\;z$\mathdefault{z}$z$\mathdefault{}$ )resubrl   )textpret_texts      r?   _wrap_in_texr   '  st    Avva/6H U+33C?HU+H 8+d2H 3R8HOrA   c                   :    \ rS rSrSrS	SS.S jjrS
S jrS rSrg)r   i7  z]
Format a tick (in days since the epoch) with a
`~datetime.datetime.strftime` format string.
Nusetexc                h    [        U5      U l        Xl        [        R                  " US5      U l        g)aV  
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@   r9   fmtr4   r5   _usetex)selfr   r9   r   s       r?   __init__DateFormatter.__init__=  s&     b/~~fm<rA   c                     [        XR                  5      R                  U R                  5      nU R                  (       a  [        U5      $ U$ N)r   r9   strftimer   r   r   )r   rp   posresults       r?   __call__DateFormatter.__call__M  s5    !WW%..txx8'+|||F#??rA   c                 $    [        U5      U l        g r   r@   r9   r   r9   s     r?   
set_tzinfoDateFormatter.set_tzinfoQ  s    b/rA   )r   r   r9   r   )r   )	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__rG   rA   r?   r   r   7  s    
=t = @"rA   r   c                   J    \ rS rSrSr  SSS.S jjrSS jrS rS rS	 r	S
r
g)r   iU  a  
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')

Nr   c                   Xl         X l        SU l        U(       a!  [        U5      S:w  a  [	        S5      eX0l        O	/ SQU l        U(       a!  [        U5      S:w  a  [	        S5      eXPl        OGU(       a  S/U R
                  SS -   U l        O'S/U R
                  SS -   U l        S	U R                  S
'   U(       a!  [        U5      S:w  a  [	        S5      eX@l        O	/ SQU l        SU l        X`l	        [        R                  " US5      U l        g)z}
Autoformat the date labels.  The default format is used to form an
initial string, and then redundant elements are removed.
%Y   z=formats argument must be a list of 6 format strings (or None))r   z%bz%d%H:%Mr   z%S.%fzBzero_formats argument must be a list of 6 format strings (or None)r   Nz%b-%d   zDoffset_formats argument must be a list of 6 format strings (or None))r   r   z%Y-%b%Y-%b-%dr   z%Y-%b-%d %H:%Mr   )_locator_tz
defaultfmtlenr;   formatszero_formatsoffset_formatsoffset_stringshow_offsetr4   r5   r   )r   locatorr9   r   r   r   r   r   s           r?   r   ConciseDateFormatter.__init__  s      7|q   "> ? ?"LDL < A%  "> ? ? ,!#t||CR'8 8D "$t||CR'8 8D#*Da >"a'  "> ? ?"0#5D  &~~fm<rA   c                 `    [        U R                  U R                  U R                  S9nU" XS9$ )Nr   )r   )r   r   r   r   )r   rp   r   	formatters       r?   r   ConciseDateFormatter.__call__  s*    !$//488)-7	$$rA   c                    U Vs/ s H  n[        X R                  S9PM     nn[        R                  " U Vs/ s H  oDR	                  5       S S PM     sn5      nU R
                  nU R                  nU R                  nU R                  n	[        SSS5       Ha  n
[        R                  " US S 2U
4   5      n[        U5      S:  a(  U
S:  a   [        R                  " US:H  5      (       a  Sn	  OU
S:X  d  M_  Sn
Mc     / S	QnS
/[        U5      -  n[        [        U5      5       Hf  nW
S:  a  X^   U
   X   :X  a  Xz   nO6Xj   nO1X>   R                  X>   R                  s=:X  a  S:X  a  O  OXz   nOXj   nX>   R                  U5      X'   Mh     W
S:  aV  [!        S U 5       S S9nU(       a>  [        [        U5      5       H&  nSX   ;   d  M  X   S U*  R#                  S5      X'   M(     U	(       a  U R$                  R&                  (       ai  U R$                  R&                  R(                  S;   aE  U R$                  R&                  R+                  5       (       a  US   R                  X   5      U l        OUS   R                  X   5      U l        U R.                  (       a  [1        U R,                  5      U l        OS
U l        U R.                  (       a  U Vs/ s H  n[1        U5      PM     sn$ U$ s  snf s  snf s  snf )Nr9   r      r   rC      Fr   )r   rC   rC   r   r   r   r   r   c              3   ~   #    U  H3  nS U;   d  M  [        U5      [        UR                  S5      5      -
  v   M5     g7f)r3   0N)r   rstrip).0rN   s     r?   	<genexpr>4ConciseDateFormatter.format_ticks.<locals>.<genexpr>  s/     Ifq,Q#ahhsm,,fs   
=-=rv   r3   )xaxisyaxis)r   r   rQ   array	timetupler   r   r   r   rangeuniquer   anysecondre   r   minr   r   axisr   get_invertedr   r   r   )r   valuesvaluetickdatetimetdttickdatefmtszerofmts
offsetfmtsr   levelr   zerovalslabelsnnr   trailing_zerosls                     r?   format_ticks!ConciseDateFormatter.format_ticks  s   BHI&884&I88LILS]]_Ra0LIJ ||$$ ((
&&
 1b"%EYYx512F6{Q19!!4!4"'K!  & )H%H&Bqy<&(/9"/C+C !$++|/?/K/K "/C+C%)2237FJ '( A: IfIN F,Bfj(%+Z0@.%A%H%H%M
 - ""MM&&//3EE**7799%1!_%=%=j>O%P"%1"%5%>%>z?P%Q"||%1$2D2D%E"!#D<<-34VLOV44Mc JI\ 5s   K2K7K<c                     U R                   $ r   )r   r   s    r?   
get_offsetConciseDateFormatter.get_offset/  s    !!!rA   c                 F    [        XR                  S9R                  S5      $ )Nr   z%Y-%m-%d %H:%M:%S)r   r   r   )r   r   s     r?   format_data_short&ConciseDateFormatter.format_data_short2  s    ((+445HIIrA   )	r   r   r   r   r   r   r   r   r   )NNNNTr   )r   r   r   r   r   r   r   r   r  r  r   rG   rA   r?   r   r   U  s8    DL GK048=@D8=t%
Rh"JrA   r   c                   :    \ rS rSrSrS	SS.S jjrS rS
S jrSrg)r    i6  aw  
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
Nr   c                R   Xl         X l        X0l        [        U R                  U5      U l        [
        R                  n[
        R                  " US5      U l        [        US   [        US   SUS   S[        -  US   S[        -  US   S[        -  US   S[        -  US	   0U l        g
)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.
r   zdate.autoformatter.yearzdate.autoformatter.monthrC   zdate.autoformatter.dayzdate.autoformatter.hourzdate.autoformatter.minutezdate.autoformatter.secondzdate.autoformatter.microsecondN)r   r   r   r   
_formatterr4   rcParamsr5   r   DAYS_PER_YEARDAYS_PER_MONTHHOURS_PER_DAYMINUTES_PER_DAYrT   rj   scaled)r   r   r9   r   r   r
  s         r?   r   AutoDateFormatter.__init__n  s    .  $'<<<~~fm<8$=>H%?@x01x(AB*E!FOX&AB!!8,L#M
rA   c                     Xl         g r   )r   )r   r   s     r?   _set_locatorAutoDateFormatter._set_locator  s    rA   c                   ^  [        U R                  R                  5       5      m[	        U4S j[        U R                  R                  5       5       5       U R                  5      n[        U[        5      (       a6  [        X0R                  U R                  S9U l        U R                  X5      nU$ [        U5      (       a
  U" X5      nU$ [!        SU < S35      e! [         a    Sm Nf = f)NrC   c              3   <   >#    U  H  u  pUT:  d  M  Uv   M     g 7fr   rG   )r   scaler   locator_unit_scales      r?   r   -AutoDateFormatter.__call__.<locals>.<genexpr>  s%      4*EJE 22 C*Es   	r   zUnexpected type passed to r3   )floatr   	_get_unitAttributeErrornextsortedr  itemsr   r6   r7   r   r   r   r	  callabler>   )r   rp   r   r   r   r  s        @r?   r   AutoDateFormatter.__call__  s    	#!&t}}'>'>'@!A  4&1B1B1D*E 4??$ c3+C$,,ODO__Q,F  c]][F  8BCC  	#!"	#s   #C C+*C+)r	  r   r   r   r   r  )Nz%Y-%m-%dr   )	r   r   r   r   r   r   r  r   r   rG   rA   r?   r    r    6  s     *n%
%
N rA   r    c                   J    \ rS rSrSrSS jrS rS rS rSS jr	S	 r
S
 rSrg)r/   i  zX
A simple wrapper around a `dateutil.rrule` allowing flexible
date tick specifications.
Nc                 <    XS'   X l         U R                  " S0 UD6  g)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)r   r#  r=   kwargss       r?   r   rrulewrapper.__init__  s"     v"$V$rA   c                 r    U R                   R                  U5        U R                  " S0 U R                   D6  g)z'Set parameters for an existing wrapper.NrG   )
_constructupdater%  )r   r&  s     r?   setrrulewrapper.set  s)    v&-T__-rA   c                    U R                   nSU;   aE  US   nUR                  b3  Uc  UR                  nOUR                  U5      nUR                  S S9US'   SU;   aD  US   nUR                  b2  Ub  UR                  U5      nO[	        S5      eUR                  S S9US'   UR                  5       U l        X l        [        S0 U R                  D6U l	        g )Ndtstartra   untilz<until cannot be aware if dtstart is naive and tzinfo is NonerG   )
r$  r=   rm   rl   r;   copyr)  _tzinfor   _rrule)r   r&  r=   r.  r/  s        r?   r%  rrulewrapper._update_rrule  s    ""
 Y'G~~)>$^^F%008G$+OO4O$@y!f7OE||'%!,,V4E$ &C D D #(--t-"<w ++-.doo.rA   c                 b    [        US5      (       a  UR                  USS9$ UR                  US9$ )NlocalizeT)is_dstra   )hasattrr5  rl   )r   r[   r=   s      r?   _attach_tzinforrulewrapper._attach_tzinfo  s3    6:&&??2d?33zzz((rA   c                    ^ ^^^ T R                   c  T$ U 4S jmU4S jmU(       d	  UUU 4S jnOUUU 4S jn[        R                  " T5      " U5      $ )z>Decorator function that allows rrule methods to handle tzinfo.c                    > [        U [        R                  5      (       aP  U R                  bC  U R                  TR                  La  U R	                  TR                  5      n U R                  S S9$ U $ )Nra   )r6   r<   r=   r1  rm   rl   )argr   s    r?   normalize_arg9rrulewrapper._aware_return_wrapper.<locals>.normalize_arg  sW    #x0011cjj6L::T\\1..6C{{${//JrA   c                    > [        U4S jU  5       5      n UR                  5        VVs0 s H  u  p#UT" U5      _M     nnnX4$ s  snnf )Nc              3   4   >#    U  H  nT" U5      v   M     g 7fr   rG   )r   r<  r=  s     r?   r   Mrrulewrapper._aware_return_wrapper.<locals>.normalize_args.<locals>.<genexpr>  s     <ts++ts   )tupler  )argsr&  kwr<  r=  s       r?   normalize_args:rrulewrapper._aware_return_wrapper.<locals>.normalize_args   sG    <t<<D<BLLNKNb-,,NFK< Ls   Ac                  `   > T" X5      u  pT" U 0 UD6nTR                  UTR                  5      $ r   r8  r1  )rC  r&  r[   frE  r   s      r?   
inner_func6rrulewrapper._aware_return_wrapper.<locals>.inner_func	  s5    -d;''**2t||<<rA   c                     > T" X5      u  pT" U 0 UD6nU Vs/ s H  nTR                  UTR                  5      PM!     sn$ s  snf r   rH  )rC  r&  dtsr[   rI  rE  r   s       r?   rJ  rK    sG    -d;((HKL"++B=LLLs   &A)r1  	functoolswraps)r   rI  returns_listrJ  r=  rE  s   ``  @@r?   _aware_return_wrapper"rrulewrapper._aware_return_wrapper  sI     <<H		  = =
M
 q!*--rA   c                     XR                   ;   a  U R                   U   $ [        U R                  U5      nUS;   a  U R                  U5      $ US;   a  U R                  USS9$ U$ )N>   afterbefore>   xafterbetweenxbeforeT)rP  )__dict__r   r2  rQ  )r   namerI  s      r?   __getattr__rrulewrapper.__getattr__  si    == ==&&DKK&&&--a0055--ad-CCHrA   c                 :    U R                   R                  U5        g r   )rY  r*  )r   states     r?   __setstate__rrulewrapper.__setstate__"  s    U#rA   )r$  r)  r2  r1  r   )F)r   r   r   r   r   r   r+  r%  r8  rQ  r[  r_  r   rG   rA   r?   r/   r/     s+    %"./>)$.L$rA   r/   c                   R    \ rS rSrSrSSSS.rSS jrS rS rS	 r	S
 r
S rS rSrg)r!   i&  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   )byhourbyminutebysecondNc                 $    [        U5      U l        g)z
Parameters
----------
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
    Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
Nr   r   s     r?   r   DateLocator.__init__/  s     b/rA   c                 $    [        U5      U l        g)z
Set timezone info.

Parameters
----------
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
    Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
Nr   r   s     r?   r   DateLocator.set_tzinfo8  s     b/rA   c                     U R                   R                  5       u  pX:  a  X!p![        XR                  5      [        X R                  5      4$ )z/Convert axis data interval to datetime objects.)r   get_data_intervalr   r9   r   dmindmaxs      r?   datalim_to_dtDateLocator.datalim_to_dtC  s=    YY002
;$gg&ww(???rA   c                     U R                   R                  5       u  pX:  a  X!p![        XR                  5      [        X R                  5      4$ )z.Convert the view interval to datetime objects.)r   get_view_intervalr   r9   r   vminvmaxs      r?   viewlim_to_dtDateLocator.viewlim_to_dtK  s=    YY002
;$gg&ww(???rA   c                     g)zR
Return how many days a unit of the locator is; used for
intelligent autoscaling.
rC   rG   r  s    r?   r  DateLocator._get_unitR  s    
 rA   c                     g)z+
Return the number of units for each tick.
rC   rG   r  s    r?   _get_intervalDateLocator._get_intervalY  s     rA   c                    [         R                  " U5      (       a  [         R                  " U5      (       dB  [        [        R                  " SSS5      5      [        [        R                  " SSS5      5      4$ X!:  a  X!p!U R                  5       nU R                  5       n[        X!-
  5      S:  a  USU-  U-  -  nUSU-  U-  -  nX4$ )zx
Given the proposed upper and lower extent, adjust the range
if it is too close to being singular (i.e. a range of ~0).
rB   rC   r   gư>)rQ   isfiniter   r<   dater  rz  rn   )r   rs  rt  unitintervals        r?   nonsingularDateLocator.nonsingular_  s    
 {{4  D(9(9X]]4A67X]]4A679 9;$~~%%'t{d"AHx''DAHx''DzrA   r   r   )r   r   r   r   r   hms0dr   r   rn  ru  r  rz  r  r   rG   rA   r?   r!   r!   &  s:     aQ7E"	"@@rA   r!   c                   Z   ^  \ rS rSrS
U 4S jjrS rS rS rS r\	S 5       r
S rS	rU =r$ )r"   ir  c                 0   > [         TU ]  U5        Xl        g r   )superr   rule)r   or9   	__class__s      r?   r   RRuleLocator.__init__u  s    	rA   c                 n     U R                  5       u  pU R                  X5      $ ! [         a    / s $ f = fr   ru  r;   tick_valuesrk  s      r?   r   RRuleLocator.__call__y  @    	++-JD ++  	I	   % 44c                     U R                  X5      u  p4U R                  R                  X4S5      n[        U5      S:X  a  [	        X/5      $ U R                  [	        U5      5      $ )NTr   )_create_rruler  rW  r   r   raise_if_exceeds)r   rs  rt  startstopdatess         r?   r  RRuleLocator.tick_values  sW    ((4		!!%t4u:?TL))$$Xe_55rA   c                    [        X!5      n X-
  n X#-   nU R                  R                  XES	9  X4$ ! [        [        4 a5    [        R                  " SSSSSS[        R                  R
                  S9n Nef = f! [        [        4 a5    [        R                  " SSSSSS[        R                  R
                  S9n Nf = f)
NrC   r   ra   '           ;   r.  r/  )r   r;   OverflowErrorr<   r1   utcr  r+  )r   rs  rt  r   r  r  s         r?   r  RRuleLocator._create_rrule  s     d)	DLE	C<D 			e0z M* 	D%%aAq!Q-5->->-B-BDE	D M* 	C$$T2r2r2,4,=,=,A,ACD	Cs"   2 A: AA76A7:AB?>B?c                 d    U R                   R                  R                  nU R                  U5      $ r   )r  r2  _freqget_unit_generic)r   r#  s     r?   r  RRuleLocator._get_unit  s(    yy%%$$T**rA   c                     U [         :X  a  [        $ U [        :X  a  [        $ U [        :X  a  [
        $ U [        :X  a  gU [        :X  a	  S[        -  $ U [        :X  a	  S[        -  $ U [        :X  a	  S[        -  $ g)N      ?r   )r   r  r   r  r   DAYS_PER_WEEKr   r   r  r   r  r   rT   )r#  s    r?   r  RRuleLocator.get_unit_generic  sp    6>  W_!!V^  U]V^&&X((X$$ rA   c                 B    U R                   R                  R                  $ r   )r  r2  	_intervalr  s    r?   rz  RRuleLocator._get_interval  s    yy)))rA   )r  r   )r   r   r   r   r   r   r  r  r  staticmethodr  rz  r   __classcell__r  s   @r?   r"   r"   r  s:    ,60+
  &* *rA   r"   c                   R   ^  \ rS rSrSr  S
U 4S jjrS rS rS rS r	S r
S	rU =r$ )r#   i  a9  
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
c                   > [         TU ]  US9  [        U l        [        [        [
        [        [        [        [        /U l
        X l        [        S[        S[
        S[        S[        S[        S[        S0U l        Ub   U R                  R                  U5        X@l        [        / SQ[        / SQ[
        / SQ[        / S	Q[        / S
Q[        / S
Q[        / SQ0U l        U(       a  / SQU R$                  [
        '   S['        SS5      ['        SS5      ['        SS5      ['        SS5      ['        SS5      S/U l        g! [         a(    [        R!                  U R                  U5      U l         Nf = f)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      r     N)rC   r      r   
   rc   (   2   d      i        i    '  )rC   r   r   r  r   )rC   r   r            )rC   r   r   r  r   r  )rC   r   r        )rC   r   r   r  rc   r  r  r  r  r  r  r  r  i N  iP  i i@ i  rd   )rC   r   r  r  r  rC          r      <   )r  r   r   r  r   r   r   r   r   r,   _freqsminticksmaxticksr*  r>   dictfromkeysinterval_multiples	intervaldr   	_byranges)r   r9   r  r  r  r  s        r?   r   AutoDateLocator.__init__  s6   2 	B
wvx0 Wb%VR!2x]AGE$$X. #5 6o*)(( %  %5DNN5!aeArl2,aeArlDJ1  E !%dkk8 D	Es   ?D< </E.-E.c                 V    U R                  5       u  pU R                  X5      nU" 5       $ r   )ru  get_locator)r   rl  rm  r   s       r?   r   AutoDateLocator.__call__%  s*    '')
""4.yrA   c                 B    U R                  X5      R                  X5      $ r   )r  r  rr  s      r?   r  AutoDateLocator.tick_values+  s    +77CCrA   c                 @   [         R                  " U5      (       a  [         R                  " U5      (       dB  [        [        R                  " SSS5      5      [        [        R                  " SSS5      5      4$ X!:  a  X!p!X:X  a  U[
        S-  -
  nU[
        S-  -   nX4$ )NrB   rC   r   )rQ   r}  r   r<   r~  r  rr  s      r?   r  AutoDateLocator.nonsingular.  s     {{4  D(9(9X]]4A67X]]4A679 9;$<-!++D-!++DzrA   c                 |    U R                   [        4;   a	  S[        -  $ [        R	                  U R                   5      $ Nr  )r  r,   rj   r"   r  r  s    r?   r  AutoDateLocator._get_unit<  s1    ::-()))00<<rA   c                    [        X!5      nX!-
  nX:  a  U* nU* n[        UR                  5      nU[        -  UR                  -   nUR
                  nU[        -  UR                  -   nU[        -  UR                  -   n	[        R                  " UR                  5       5      n
[        R                  " UR                  5       S-  5      nXVXxU	X/nS/S-  S/-   n/ SQn[        [        U R                  U5      5       GH  u  nu  nnUU R                   :  a  SX'   M   U R"                  U    H  nUUU R$                  U   S-
  -  ::  d  M    O7   U R&                  (       a
  U[(        :X  d  [*        R,                  " SW S	35        UU l        U R0                  U   (       aT  U R&                  (       aC  U R0                  U   SSW2   X'   U[(        [2        4;   a  US
:X  a  SS/X'   OUS:X  a  / SQX'   SnOU R0                  U   X'     O   SnW[4        :X  a&  U R&                  (       a  [7        WU R8                  S9nOUW   (       a9  Uu  nnnnnnn[;        U R.                  WXUUUUUS9	n[=        UU R8                  S9nOK[?        WU R8                  S9n[A        U5      S:  a(  US:  a"  [*        R,                  " S[C        5        S35        URE                  U RF                  5        U$ )z*Pick the best locator based on a distance.rD   Tr   F)NrC   rC   r   r   r   NNrC   zAutoDateLocator was unable to pick an appropriate interval for this date range. It may be necessary to add an interval value to the AutoDateLocator's intervald dictionary. Defaulting to r3   r  r  r  )rC   r  r     r   )r  r.  r/  bymonth
bymonthdayrb  rc  rd  rb   r  zOPlotting microsecond time intervals for dates far from the epoch (time origin: zL) is not well-supported. See matplotlib.dates.set_epoch to change the epoch.)$r   r  yearsMONTHS_PER_YEARmonthsr   r  hoursMIN_PER_HOURminutesrQ   floorr   	enumeratezipr  r  r  r  r  r   r   warn_externalr  r  r   r   r$   r9   r/   r"   r+   r   r   set_axisr   )r   rl  rm  r   tdeltanumYears	numMonthsnumDaysnumHours
numMinutes
numSecondsnumMicrosecondsnumsuse_rrule_locatorbyrangesir#  r   r  r   _r  r  rb  rc  rd  r   s                              r?   r  AutoDateLocator.get_locatorB  s   d) ;FEWF
 %.=	++]*U[[8,u}}<
XXf2245
((6#7#7#9C#?@W
- "FQJ%0
 / (DKK(>?NA{cT]]" # !NN40(dmmD&9A&=>> 1 //DEM&&? @HjKL DJ~~a T%<%<"nnQ/
(
;'2~'("g!Q&4"nnQ/K @N HFN 7 7!(tww7Gq!DLAAw
FHh h)-)0Z(.*2	4E #5TWW5G(dgg>G~(X_""//8{m < 	#rA   )r  r  r  r  r  r  r  )Nr   NT)r   r   r   r   r   r   r   r  r  r  r  r   r  r  s   @r?   r#   r#     s9    %N 6:$(=J~D=b brA   r#   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )r$   i  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)
c                    > [        [        4XUS.U R                  D6n[        TU ]  XTS9  [
        R                  " US5      U l        g)av  
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  r  r  r   r   N)r/   r   r  r  r   r   _Edge_integerbase)r   r  monthdayr9   r  r  s         r?   r   YearLocator.__init__  sK     F :T'*:.2jj:%((q1	rA   c                    [        U R                  R                  UR                  5      U R                  R                  -  S5      n[        U R                  R                  UR                  5      U R                  R                  -  S5      nU R                  R                  nUUR                  SS5      UR                  SS5      SSSS.nUR                  " S	0 UD6nUR                  US9nU R                  R                  XxS9  Xx4$ )
NrC   r  r  r  r   )yearr  r  hourminuter   )r   r  rG   )maxr  ler   r   r   ger  r)  getrl   r+  )	r   rs  rt  yminymaxcrl   r  r  s	            r?   r  YearLocator._create_rrule  s     499<<		*TYY^^;Q?499<<		*TYY^^;TBII  EE)Q/%%a0Q8
 'w'}}$}'		e0{rA   )r  )rC   rC   rC   N)	r   r   r   r   r   r   r  r   r  r  s   @r?   r$   r$     s    
2& rA   r$   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r%   i  z:
Make ticks on occurrences of each month, e.g., 1, 3, 12.
c                 x   > Uc  [        SS5      n[        [        4XUS.U R                  D6n[        TU ]  XTS9  g)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`.
NrC   r  )r  r  r  r   )r   r/   r   r  r  r   )r   r  r  r  r9   r  r  s         r?   r   MonthLocator.__init__  sG     ?ArlGG =W%-=15=%rA   rG   )NrC   rC   Nr   r   r   r   r   r   r   r  r  s   @r?   r%   r%     s    & &rA   r%   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r&   i  z,
Make ticks on occurrences of each weekday.
c                 Z   > [        [        4UUS.U R                  D6n[        TU ]  XCS9  g)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  r   N)r/   r   r  r  r   )r   r  r  r9   r  r  s        r?   r   WeekdayLocator.__init__  s7    " E =Y%-=15=%rA   rG   )rC   rC   Nr  r  s   @r?   r&   r&     s    & &rA   r&   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r'   i  zN
Make ticks on occurrences of each day of the month.  For example,
1, 15, 30.
c                    > U[        U5      :w  d  US:  a  [        S5      eUc  [        SS5      n[        [        4UUS.U R
                  D6n[        TU ]  XCS9  g)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`.
rC   z*interval must be an integer greater than 0Nr  )r  r  r   )rh   r;   r   r/   r   r  r  r   )r   r  r  r9   r  r  s        r?   r   DayLocator.__init__  sf     s8}$1IJJq"JE =j%-=15=%rA   rG   NrC   Nr  r  s   @r?   r'   r'     s    & &rA   r'   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r(   i+  z)
Make ticks on occurrences of each hour.
c                 \   > Uc  [        S5      n[        [        XSSS9n[        TU ]  XCS9  g)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`.
Nr  r   )rb  r  rc  rd  r   )r   r/   r   r  r   )r   rb  r  r9   r  r  s        r?   r   HourLocator.__init__/  s6     >2YFF6%&4%rA   rG   r  r  r  s   @r?   r(   r(   +      & &rA   r(   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r)   iD  z+
Make ticks on occurrences of each minute.
c                 Z   > Uc  [        S5      n[        [        XSS9n[        TU ]  XCS9  g)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`.
Nr  r   )rc  r  rd  r   )r   r/   r   r  r   )r   rc  r  r9   r  r  s        r?   r   MinuteLocator.__init__H  s5     RyHHx%&(%rA   rG   r  r  r  s   @r?   r)   r)   D  r  rA   r)   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r*   i]  z+
Make ticks on occurrences of each second.
c                 X   > Uc  [        S5      n[        [        XS9n[        TU ]  XCS9  g)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  )rd  r  r   )r   r/   r   r  r   )r   rd  r  r9   r  r  s        r?   r   SecondLocator.__init__a  s0     RyHHxK%rA   rG   r  r  r  s   @r?   r*   r*   ]  s    & &rA   r*   c                   T   ^  \ rS rSrSrS
U 4S jjrU 4S jrS rS rS r	S r
S	rU =r$ )r+   iu  a  
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`.

c                 b   > [         TU ]  US9  Xl        [        R                  " U5      U l        g)a  
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`.
r   N)r  r   r  r   MultipleLocator_wrapped_locator)r   r  r9   r  s      r?   r   MicrosecondLocator.__init__  s-     	B! & 6 6x @rA   c                 X   > U R                   R                  U5        [        TU ]  U5      $ r   )r$  r  r  )r   r   r  s     r?   r  MicrosecondLocator.set_axis  s'    &&t,w%%rA   c                 n     U R                  5       u  pU R                  X5      $ ! [         a    / s $ f = fr   r  rk  s      r?   r   MicrosecondLocator.__call__  r  r  c                     [        X45      u  p4[        R                  " U5      nXE-
  nX5-
  nU[        -  nU[        -  nU R                  R                  X45      nU[        -  U-   nU$ r   )r   rQ   r  rj   r$  r  )r   rs  rt  nminnmaxrZ   tickss          r?   r  MicrosecondLocator.tick_values  sl    tl+
XXd^yy!!!!%%11$=))B.rA   c                     S[         -  $ r  )rj   r  s    r?   r  MicrosecondLocator._get_unit  s    %%%rA   c                     U R                   $ r   )r  r  s    r?   rz   MicrosecondLocator._get_interval  s    ~~rA   )r  r$  )rC   N)r   r   r   r   r   r   r  r   r  r  rz  r   r  r  s   @r?   r+   r+   u  s,    *A&,& rA   r+   c                   Z   ^  \ rS rSrSrSS.U 4S jjrS r\S 5       r\S 5       r	S	r
U =r$ )
r-   i  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.
Tr  c                .   > Xl         [        TU ]	  5         g r   )_interval_multiplesr  r   )r   r  r  s     r?   r   DateConverter.__init__  s    #5 rA   c                     Un[        UU R                  S9n[        XCS9n[        R                  " SSS5      n[        R                  " SSS5      n[
        R                  " XESXg4S9$ )z
Return the `~matplotlib.units.AxisInfo` for *unit*.

*unit* is a `~datetime.tzinfo` instance or None.
The *axis* argument is required but not used.
r9   r  r   rB   rC   r   r   majlocmajfmtlabeldefault_limits)r#   r6  r    r<   r~  r   AxisInfor   r  r   r9   r;  r<  datemindatemaxs           r?   axisinfoDateConverter.axisinfo  sj      B484L4LN"61--a+--a+~~V".5-?A 	ArA   c                     [        U 5      $ )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   )r   r  r   s      r?   convertDateConverter.convert  s     rA   c                     [        U [        R                  5      (       a  U R                  5       n  [        R
                  " U 5      n  U R                  $ ! [        [        4 a     Nf = f! [         a     gf = f)zP
Return the `~datetime.tzinfo` instance of *x* or of its first element,
or None
N)
r6   rQ   ndarrayravelr   _safe_first_finiter>   StopIterationr=   r  )rp   r   s     r?   default_unitsDateConverter.default_units  sr     a$$	A	((+A	88O	 =) 		
  		s#   A A* A'&A'*
A76A7)r6  )r   r   r   r   r   r   rC  r  rF  rM  r   r  r  s   @r?   r-   r-     sE     .2  A$    rA   r-   c                   >   ^  \ rS rSr  SSS.U 4S jjjrS rSrU =r$ )r.   i  Tr4  c                ^   > Xl         X l        X0l        X@l        XPl        [
        TU ]  5         g r   )_formats_zero_formats_offset_formats_show_offsetr6  r  r   )r   r   r   r   r   r  r  s         r?   r   ConciseDateConverter.__init__  s+    )-'#5 rA   c           	      &   Un[        UU R                  S9n[        XCU R                  U R                  U R
                  U R                  S9n[        R                  " SSS5      n[        R                  " SSS5      n[        R                  " XESXg4S9$ )Nr9  )r9   r   r   r   r   rB   rC   r   r   r:  )r#   r6  r   rQ  rR  rS  rT  r<   r~  r   r?  r@  s           r?   rC  ConciseDateConverter.axisinfo  s     B484L4LN%fT]]373E3E595I5I262C2CE --a+--a+~~V".5-?A 	ArA   )rQ  r6  rS  rT  rR  )NNNT)r   r   r   r   r   rC  r   r  r  s   @r?   r.   r.     s+     HL!9= A ArA   r.   c                   :    \ rS rSrSr\S 5       rS rS rS r	Sr
g)	_SwitchableDateConverteri  z
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                  v    [         [        S.[        R                  S      n [        R                  S   nU " US9$ )N)conciseautozdate.converterzdate.interval_multiplesr4  )r.   r-   r4   r
  )converter_clsr  s     r?   _get_converter'_SwitchableDateConverter._get_converter  sA     ,]D-.0 !\\*CD0BCCrA   c                 B    U R                  5       R                  " U0 UD6$ r   )r^  rC  r   rC  r&  s      r?   rC  !_SwitchableDateConverter.axisinfo#  s!    ""$--t>v>>rA   c                 B    U R                  5       R                  " U0 UD6$ r   )r^  rM  ra  s      r?   rM  &_SwitchableDateConverter.default_units&  s!    ""$22DCFCCrA   c                 B    U R                  5       R                  " U0 UD6$ r   )r^  rF  ra  s      r?   rF   _SwitchableDateConverter.convert)  s!    ""$,,d=f==rA   rG   N)r   r   r   r   r   r  r^  rC  rM  rF  r   rG   rA   r?   rY  rY    s-     D D?D>rA   rY  r   )lr   r<   rN  loggingr   dateutil.rruler   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   dateutil.relativedeltar   dateutil.parserr8   dateutil.tznumpyrQ   
matplotlibr4   r   r   r   r   __all__	getLoggerr   _logr1   r  r2   r@   r  	toordinalEPOCH_OFFSETr,   r  r  SEC_PER_MINr  r  r  r  r  SEC_PER_HOURrT   SEC_PER_WEEKrj   MONDAYTUESDAY	WEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAYWEEKDAYSrF   rH   r   r   r^   rr   	vectorizer   rx   ry   r|   r   r   r   r   r   r   r   	Formatterr   r   r    r/   Locatorr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   ConversionInterfacer-   r.   rY  registryrR   r~  rG   rA   r?   <module>r     s  m^    	& & & & & 1     1 1	D "J( X&&tQ2<<>?1.\)]*]*+%  BBBB  >HfhGY&(FK 
:0$P  "||N3G ')||HOO4I4I'J $A41#h8< (*||((6 $<&&(R
 "F$$ "<^J6++ ^JBt(( tnv$ v$rI&.. IXI*; I*Xfk fR/, /d&< &6&\ &6& &8&, &2&L &2&L &0D DN:E-- :zA= A6> >8 r}}  	NN8==!	NN8$$%rA   