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

Skip to content

Commit b755888

Browse files
committed
DOC: API note
1 parent c456ad8 commit b755888

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Changed default `AutoDateLocator` kwarg ``interval_multiples`` to ``True``
2+
--------------------------------------------------------------------------
3+
4+
The default value of the tick locator for dates, `.dates.AutoDateLocator`
5+
kwarg ``interval_multiples`` was set to ``False`` which leads to not-nice
6+
looking automatic ticks in many instances. The much nicer
7+
``interval_multiples=True`` is the new default. See below to get the
8+
old behavior back:
9+
10+
.. plot::
11+
12+
import matplotlib.pyplot as plt
13+
import datetime
14+
import matplotlib.dates as mdates
15+
16+
t0 = datetime.datetime(2009, 8, 20, 1, 10, 12)
17+
tf = datetime.datetime(2009, 8, 20, 1, 42, 11)
18+
19+
20+
fig, axs = plt.subplots(1, 2, constrained_layout=True)
21+
ax = axs[0]
22+
ax.axhspan(t0, tf, facecolor="blue", alpha=0.25)
23+
ax.set_ylim(t0 - datetime.timedelta(minutes=3),
24+
tf + datetime.timedelta(minutes=3))
25+
ax.set_title('NEW DEFAULT')
26+
27+
ax = axs[1]
28+
ax.axhspan(t0, tf, facecolor="blue", alpha=0.25)
29+
ax.set_ylim(t0 - datetime.timedelta(minutes=3),
30+
tf + datetime.timedelta(minutes=3))
31+
# old behavior
32+
locator = mdates.AutoDateLocator(interval_multiples=False, )
33+
ax.yaxis.set_major_locator(locator)
34+
ax.yaxis.set_major_formatter(mdates.AutoDateFormatter(locator))
35+
36+
ax.set_title('OLD')
37+
plt.show()

0 commit comments

Comments
 (0)