Skip to content

Clarify docs of AutoDateLocator.intervald #17664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,14 +1215,14 @@ class AutoDateLocator(DateLocator):
----------
intervald : dict

Mapping of tick frequencies (a constant from dateutil.rrule) to
multiples allowed for that ticking. The default looks like this::
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],
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],
Expand All @@ -1231,10 +1231,16 @@ class AutoDateLocator(DateLocator):
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.
You can customize this dictionary by doing::

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
Expand Down