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

Skip to content

Commit e94428b

Browse files
committed
Simplify example.
1 parent fb6890b commit e94428b

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

doc/users/next_whats_new/imshow_extent_units.rst

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ can now be expressed with units.
88

99
import matplotlib.pyplot as plt
1010
import numpy as np
11-
from matplotlib.dates import HourLocator, ConciseDateFormatter
12-
from matplotlib.ticker import AutoMinorLocator
11+
from matplotlib.dates import DateFormatter
1312

1413
fig, ax = plt.subplots(layout='constrained')
1514
date_first = np.datetime64('2020-01-01', 'D')
@@ -19,15 +18,6 @@ can now be expressed with units.
1918

2019
ax.imshow(arr, origin='lower', extent=[1, 11, date_first, date_last])
2120

22-
# customize tick locations and labels
23-
locator = HourLocator(byhour=[0, 12])
24-
ax.yaxis.set_major_formatter(
25-
ConciseDateFormatter(
26-
locator, show_offset=False,
27-
zero_formats=['', '%Y', '%b', '%b-%d %H:%M', '%H:%M', '%H:%M']
28-
)
29-
)
30-
ax.yaxis.set_major_locator(locator)
31-
ax.yaxis.set_minor_locator(AutoMinorLocator())
21+
ax.yaxis.set_major_formatter(DateFormatter('%d/%m/%y'))
3222

3323
plt.show()

0 commit comments

Comments
 (0)