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

Skip to content

Commit dfd8924

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

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
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+
import matplotlib.pyplot as plt
14+
import numpy as np
15+
16+
dates = np.arange('2001-01-10', '2001-05-23', dtype='datetime64[D]')
17+
y = np.sin(dates.astype(float) / 10)
18+
fig, axs = plt.subplots(nrows=2, constrained_layout=True)
19+
20+
plt.rcParams['date.converter'] = 'concise'
21+
plt.rcParams['date.interval_multiples'] = True
22+
ax = axs[0]
23+
ax.plot(dates, y)
24+
25+
plt.rcParams['date.converter'] = 'auto'
26+
plt.rcParams['date.interval_multiples'] = False
27+
ax = axs[1]
28+
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)