Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 51ce677

Browse filesBrowse files
authored
DOC: numpydoc-ify date Locator classes (#23438)
Also, fixes #15710
1 parent 2716c82 commit 51ce677
Copy full SHA for 51ce677

File tree

1 file changed

+96
-44
lines changed
Filter options

1 file changed

+96
-44
lines changed

‎lib/matplotlib/dates.py

Copy file name to clipboardExpand all lines: lib/matplotlib/dates.py
+96-44Lines changed: 96 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def __init__(self, fmt, tz=None, *, usetex=None):
617617
fmt : str
618618
`~datetime.datetime.strftime` format string
619619
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
620-
Ticks timezone.
620+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
621621
usetex : bool, default: :rc:`text.usetex`
622622
To enable/disable the use of TeX's math mode for rendering the
623623
results of the formatter.
@@ -650,7 +650,7 @@ class ConciseDateFormatter(ticker.Formatter):
650650
Locator that this axis is using.
651651
652652
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
653-
Passed to `.dates.num2date`.
653+
Ticks timezone, passed to `.dates.num2date`.
654654
655655
formats : list of 6 strings, optional
656656
Format strings for 6 levels of tick labelling: mostly years,
@@ -922,8 +922,8 @@ def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d', *,
922922
locator : `.ticker.Locator`
923923
Locator that this axis is using.
924924
925-
tz : str or `~datetime.tzinfo`, optional
926-
Passed to `.dates.num2date`.
925+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
926+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
927927
928928
defaultfmt : str
929929
The default format to use if none of the values in ``self.scaled``
@@ -1111,12 +1111,18 @@ def __init__(self, tz=None):
11111111
Parameters
11121112
----------
11131113
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1114+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
11141115
"""
11151116
self.tz = _get_tzinfo(tz)
11161117

11171118
def set_tzinfo(self, tz):
11181119
"""
1119-
Set timezone info. str or `~datetime.tzinfo`.
1120+
Set timezone info.
1121+
1122+
Parameters
1123+
----------
1124+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1125+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
11201126
"""
11211127
self.tz = _get_tzinfo(tz)
11221128

@@ -1289,7 +1295,7 @@ def __init__(self, tz=None, minticks=5, maxticks=None,
12891295
Parameters
12901296
----------
12911297
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1292-
Ticks timezone.
1298+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
12931299
minticks : int
12941300
The minimum number of ticks desired; controls whether ticks occur
12951301
yearly, monthly, etc.
@@ -1490,8 +1496,17 @@ class YearLocator(RRuleLocator):
14901496
"""
14911497
def __init__(self, base=1, month=1, day=1, tz=None):
14921498
"""
1493-
Mark years that are multiple of base on a given month and day
1494-
(default jan 1).
1499+
Parameters
1500+
----------
1501+
base : int, default: 1
1502+
Mark ticks every *base* years.
1503+
month : int, default: 1
1504+
The month on which to place the ticks, starting from 1. Default is
1505+
January.
1506+
day : int, default: 1
1507+
The day on which to place the ticks.
1508+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1509+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
14951510
"""
14961511
rule = rrulewrapper(YEARLY, interval=base, bymonth=month,
14971512
bymonthday=day, **self.hms0d)
@@ -1523,11 +1538,18 @@ class MonthLocator(RRuleLocator):
15231538
"""
15241539
def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None):
15251540
"""
1526-
Mark every month in *bymonth*; *bymonth* can be an int or
1527-
sequence. Default is ``range(1, 13)``, i.e. every month.
1528-
1529-
*interval* is the interval between each iteration. For
1530-
example, if ``interval=2``, mark every second occurrence.
1541+
Parameters
1542+
----------
1543+
bymonth : int or list of int, default: all months
1544+
Ticks will be placed on every month in *bymonth*. Default is
1545+
``range(1, 13)``, i.e. every month.
1546+
bymonthday : int, default: 1
1547+
The day on which to place the ticks.
1548+
interval : int, default: 1
1549+
The interval between each iteration. For example, if
1550+
``interval=2``, mark every second occurrence.
1551+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1552+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
15311553
"""
15321554
if bymonth is None:
15331555
bymonth = range(1, 13)
@@ -1544,15 +1566,20 @@ class WeekdayLocator(RRuleLocator):
15441566

15451567
def __init__(self, byweekday=1, interval=1, tz=None):
15461568
"""
1547-
Mark every weekday in *byweekday*; *byweekday* can be a number or
1548-
sequence.
1549-
1550-
Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA,
1551-
SU, the constants from :mod:`dateutil.rrule`, which have been
1552-
imported into the :mod:`matplotlib.dates` namespace.
1553-
1554-
*interval* specifies the number of weeks to skip. For example,
1555-
``interval=2`` plots every second week.
1569+
Parameters
1570+
----------
1571+
byweekday : int or list of int, default: all days
1572+
Ticks will be placed on every weekday in *byweekday*. Default is
1573+
every day.
1574+
1575+
Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA,
1576+
SU, the constants from :mod:`dateutil.rrule`, which have been
1577+
imported into the :mod:`matplotlib.dates` namespace.
1578+
interval : int, default: 1
1579+
The interval between each iteration. For example, if
1580+
``interval=2``, mark every second occurrence.
1581+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1582+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
15561583
"""
15571584
rule = rrulewrapper(DAILY, byweekday=byweekday,
15581585
interval=interval, **self.hms0d)
@@ -1566,9 +1593,16 @@ class DayLocator(RRuleLocator):
15661593
"""
15671594
def __init__(self, bymonthday=None, interval=1, tz=None):
15681595
"""
1569-
Mark every day in *bymonthday*; *bymonthday* can be an int or sequence.
1570-
1571-
Default is to tick every day of the month: ``bymonthday=range(1, 32)``.
1596+
Parameters
1597+
----------
1598+
bymonthday : int or list of int, default: all days
1599+
Ticks will be placed on every day in *bymonthday*. Default is
1600+
``bymonthday=range(1, 32)``, i.e., every day of the month.
1601+
interval : int, default: 1
1602+
The interval between each iteration. For example, if
1603+
``interval=2``, mark every second occurrence.
1604+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1605+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
15721606
"""
15731607
if interval != int(interval) or interval < 1:
15741608
raise ValueError("interval must be an integer greater than 0")
@@ -1586,11 +1620,16 @@ class HourLocator(RRuleLocator):
15861620
"""
15871621
def __init__(self, byhour=None, interval=1, tz=None):
15881622
"""
1589-
Mark every hour in *byhour*; *byhour* can be an int or sequence.
1590-
Default is to tick every hour: ``byhour=range(24)``
1591-
1592-
*interval* is the interval between each iteration. For
1593-
example, if ``interval=2``, mark every second occurrence.
1623+
Parameters
1624+
----------
1625+
byhour : int or list of int, default: all hours
1626+
Ticks will be placed on every hour in *byhour*. Default is
1627+
``byhour=range(24)``, i.e., every hour.
1628+
interval : int, default: 1
1629+
The interval between each iteration. For example, if
1630+
``interval=2``, mark every second occurrence.
1631+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1632+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
15941633
"""
15951634
if byhour is None:
15961635
byhour = range(24)
@@ -1606,11 +1645,16 @@ class MinuteLocator(RRuleLocator):
16061645
"""
16071646
def __init__(self, byminute=None, interval=1, tz=None):
16081647
"""
1609-
Mark every minute in *byminute*; *byminute* can be an int or
1610-
sequence. Default is to tick every minute: ``byminute=range(60)``
1611-
1612-
*interval* is the interval between each iteration. For
1613-
example, if ``interval=2``, mark every second occurrence.
1648+
Parameters
1649+
----------
1650+
byminute : int or list of int, default: all minutes
1651+
Ticks will be placed on every minutes in *byminutes*. Default is
1652+
``byminute=range(60)``, i.e., every minute.
1653+
interval : int, default: 1
1654+
The interval between each iteration. For example, if
1655+
``interval=2``, mark every second occurrence.
1656+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1657+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
16141658
"""
16151659
if byminute is None:
16161660
byminute = range(60)
@@ -1626,12 +1670,16 @@ class SecondLocator(RRuleLocator):
16261670
"""
16271671
def __init__(self, bysecond=None, interval=1, tz=None):
16281672
"""
1629-
Mark every second in *bysecond*; *bysecond* can be an int or
1630-
sequence. Default is to tick every second: ``bysecond = range(60)``
1631-
1632-
*interval* is the interval between each iteration. For
1633-
example, if ``interval=2``, mark every second occurrence.
1634-
1673+
Parameters
1674+
----------
1675+
bysecond : int or list of int, default: all seconds
1676+
Ticks will be placed on every second in *bysecond*. Default is
1677+
``bysecond = range(60)``, i.e., every second.
1678+
interval : int, default: 1
1679+
The interval between each iteration. For example, if
1680+
``interval=2``, mark every second occurrence.
1681+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1682+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
16351683
"""
16361684
if bysecond is None:
16371685
bysecond = range(60)
@@ -1664,9 +1712,13 @@ class MicrosecondLocator(DateLocator):
16641712
"""
16651713
def __init__(self, interval=1, tz=None):
16661714
"""
1667-
*interval* is the interval between each iteration. For
1668-
example, if ``interval=2``, mark every second microsecond.
1669-
1715+
Parameters
1716+
----------
1717+
interval : int, default: 1
1718+
The interval between each iteration. For example, if
1719+
``interval=2``, mark every second occurrence.
1720+
tz : str or `~datetime.tzinfo`, default: :rc:`timezone`
1721+
Ticks timezone. If a string, *tz* is passed to `dateutil.tz`.
16701722
"""
16711723
super().__init__(tz=tz)
16721724
self._interval = interval

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.