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

Skip to content

Commit 53458cc

Browse files
committed
TST: check bar and barh work with timedelta
1 parent 15edda9 commit 53458cc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,29 @@ def test_barh_tick_label():
14811481
align='center')
14821482

14831483

1484+
def test_bar_timedelta():
1485+
"""smoketest that bar can handle width and height in delta units"""
1486+
fig, ax = plt.subplots()
1487+
ax.bar(datetime.datetime(2018, 1, 1), 1.,
1488+
width=datetime.timedelta(hours=3))
1489+
ax.bar(datetime.datetime(2018, 1, 1), 1.,
1490+
xerr=datetime.timedelta(hours=2),
1491+
width=datetime.timedelta(hours=3))
1492+
fig, ax = plt.subplots()
1493+
ax.barh(datetime.datetime(2018, 1, 1), 1,
1494+
height=datetime.timedelta(hours=3))
1495+
ax.barh(datetime.datetime(2018, 1, 1), 1,
1496+
height=datetime.timedelta(hours=3),
1497+
yerr=datetime.timedelta(hours=2))
1498+
fig, ax = plt.subplots()
1499+
ax.barh([datetime.datetime(2018, 1, 1), datetime.datetime(2018, 1, 1)],
1500+
np.array([1, 1.5]),
1501+
height=datetime.timedelta(hours=3))
1502+
ax.barh([datetime.datetime(2018, 1, 1), datetime.datetime(2018, 1, 1)],
1503+
np.array([1, 1.5]),
1504+
height=[datetime.timedelta(hours=t) for t in [1, 2]])
1505+
1506+
14841507
@image_comparison(baseline_images=['hist_log'],
14851508
remove_text=True)
14861509
def test_hist_log():

0 commit comments

Comments
 (0)