From 3b53e9dcc288c0fd1fe24b7b540c5f8948bcf6df Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 14 May 2022 16:05:49 +0200 Subject: [PATCH] Add rrulewrapper to docs --- doc/api/dates_api.rst | 1 + lib/matplotlib/dates.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/api/dates_api.rst b/doc/api/dates_api.rst index 1150094aed1a..7a3e3bcf4a95 100644 --- a/doc/api/dates_api.rst +++ b/doc/api/dates_api.rst @@ -9,4 +9,5 @@ .. automodule:: matplotlib.dates :members: :undoc-members: + :exclude-members: rrule :show-inheritance: diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index b63016fb75a6..30b2f40466f0 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -142,8 +142,8 @@ * `YearLocator`: Locate years that are multiples of base. -* `RRuleLocator`: Locate using a ``matplotlib.dates.rrulewrapper``. - ``rrulewrapper`` is a simple wrapper around dateutil_'s `dateutil.rrule` +* `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 `. @@ -195,7 +195,7 @@ 'rrule', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU', 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY', 'MINUTELY', 'SECONDLY', 'MICROSECONDLY', 'relativedelta', - 'DateConverter', 'ConciseDateConverter') + 'DateConverter', 'ConciseDateConverter', 'rrulewrapper') _log = logging.getLogger(__name__) @@ -981,16 +981,28 @@ def __call__(self, x, pos=None): class rrulewrapper: """ - A simple wrapper around a ``dateutil.rrule`` allowing flexible + A simple wrapper around a `dateutil.rrule` allowing flexible date tick specifications. """ def __init__(self, freq, tzinfo=None, **kwargs): + """ + 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`. + """ kwargs['freq'] = freq self._base_tzinfo = tzinfo self._update_rrule(**kwargs) def set(self, **kwargs): + """Set parameters for an existing wrapper.""" self._construct.update(kwargs) self._update_rrule(**self._construct)