Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f29425

Browse files
committed
DOC: add example to whats new
1 parent 44b564f commit 4f29425

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
New rcParams for dates: set converter and whether to use interval_multiples
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4-
The new :rc:`dates.converter` allows toggling between
4+
The new :rc:`date.converter` allows toggling between
55
`matplotlib.dates.DateConverter` and `matplotlib.dates.ConciseDateConverter`
66
using the strings 'auto' and 'concise' respectively.
77

8-
The new :rc:`dates.interval_multiples` allows toggling between the dates
8+
The new :rc:`date.interval_multiples` allows toggling between the dates
99
locator trying to pick ticks at set intervals (i.e. day 1 and 15 of the
1010
month), versus evenly spaced ticks that start where ever the
11-
timeseries starts.
11+
timeseries starts:
12+
13+
.. plot::
14+
:include-source: True
15+
16+
import matplotlib.pyplot as plt
17+
import numpy as np
18+
19+
dates = np.arange('2001-01-10', '2001-05-23', dtype='datetime64[D]')
20+
y = np.sin(dates.astype(float) / 10)
21+
fig, axs = plt.subplots(nrows=2, constrained_layout=True)
22+
23+
plt.rcParams['date.converter'] = 'concise'
24+
plt.rcParams['date.interval_multiples'] = True
25+
ax = axs[0]
26+
ax.plot(dates, y)
27+
28+
plt.rcParams['date.converter'] = 'auto'
29+
plt.rcParams['date.interval_multiples'] = False
30+
ax = axs[1]
31+
ax.plot(dates, y)

lib/matplotlib/dates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,7 @@ class DateConverter(units.ConversionInterface):
18321832
The 'unit' tag for such data is None or a tzinfo instance.
18331833
"""
18341834

1835-
def __init__(self, interval_multiples=True):
1835+
def __init__(self, *, interval_multiples=True):
18361836
self._interval_multiples = interval_multiples
18371837
super().__init__()
18381838

@@ -1888,7 +1888,7 @@ class ConciseDateConverter(DateConverter):
18881888
# docstring inherited
18891889

18901890
def __init__(self, formats=None, zero_formats=None, offset_formats=None,
1891-
show_offset=True, interval_multiples=True):
1891+
show_offset=True, *, interval_multiples=True):
18921892
self._formats = formats
18931893
self._zero_formats = zero_formats
18941894
self._offset_formats = offset_formats

0 commit comments

Comments
 (0)