Skip to content

Commit

Permalink
DOC: add example to whats new
Browse files Browse the repository at this point in the history
  • Loading branch information
jklymak committed Jun 25, 2020
1 parent 44b564f commit 4f29425
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 23 additions & 3 deletions doc/users/next_whats_new/rcparams_dates.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
New rcParams for dates: set converter and whether to use interval_multiples
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The new :rc:`dates.converter` allows toggling between
The new :rc:`date.converter` allows toggling between
`matplotlib.dates.DateConverter` and `matplotlib.dates.ConciseDateConverter`
using the strings 'auto' and 'concise' respectively.

The new :rc:`dates.interval_multiples` allows toggling between the dates
The new :rc:`date.interval_multiples` allows toggling between the dates
locator trying to pick ticks at set intervals (i.e. day 1 and 15 of the
month), versus evenly spaced ticks that start where ever the
timeseries starts.
timeseries starts:

.. plot::
:include-source: True

import matplotlib.pyplot as plt
import numpy as np

dates = np.arange('2001-01-10', '2001-05-23', dtype='datetime64[D]')
y = np.sin(dates.astype(float) / 10)
fig, axs = plt.subplots(nrows=2, constrained_layout=True)

plt.rcParams['date.converter'] = 'concise'
plt.rcParams['date.interval_multiples'] = True
ax = axs[0]
ax.plot(dates, y)

plt.rcParams['date.converter'] = 'auto'
plt.rcParams['date.interval_multiples'] = False
ax = axs[1]
ax.plot(dates, y)
4 changes: 2 additions & 2 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,7 @@ class DateConverter(units.ConversionInterface):
The 'unit' tag for such data is None or a tzinfo instance.
"""

def __init__(self, interval_multiples=True):
def __init__(self, *, interval_multiples=True):
self._interval_multiples = interval_multiples
super().__init__()

Expand Down Expand Up @@ -1888,7 +1888,7 @@ class ConciseDateConverter(DateConverter):
# docstring inherited

def __init__(self, formats=None, zero_formats=None, offset_formats=None,
show_offset=True, interval_multiples=True):
show_offset=True, *, interval_multiples=True):
self._formats = formats
self._zero_formats = zero_formats
self._offset_formats = offset_formats
Expand Down

0 comments on commit 4f29425

Please sign in to comment.