Skip to content

Commit d674917

Browse files
test for timedelta xoffset
1 parent 78c1611 commit d674917

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

labellines/test.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime
1+
from datetime import datetime, timedelta
22

33
import matplotlib.pyplot as plt
44
import numpy as np
@@ -168,6 +168,19 @@ def test_dateaxis_advanced(setup_mpl):
168168
return plt.gcf()
169169

170170

171+
@pytest.mark.mpl_image_compare
172+
def test_dateaxis_timedelta_xoffset(setup_mpl):
173+
dates = [datetime(2018, 11, 1), datetime(2018, 11, 2), datetime(2018, 11, 3)]
174+
dt = timedelta(hours=12)
175+
176+
plt.plot(dates, [0, 1, 2], label="apples")
177+
plt.plot(dates, [3, 4, 5], label="banana")
178+
ax = plt.gca()
179+
180+
labelLines(ax.get_lines(), xoffsets=dt)
181+
return plt.gcf()
182+
183+
171184
@pytest.mark.mpl_image_compare
172185
def test_polar(setup_mpl):
173186
t = np.linspace(0, 2 * np.pi, num=128)

0 commit comments

Comments
 (0)