Skip to content

Commit a3ef0ee

Browse files
Fix build error
1 parent 408486a commit a3ef0ee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

labellines/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
import matplotlib.pyplot as plt
55
import numpy as np
6+
from datetime import datetime
67
from matplotlib.container import ErrorbarContainer
7-
from matplotlib.dates import DateConverter, num2date
8+
from matplotlib.dates import DateConverter, num2date, _SwitchableDateConverter
89
from matplotlib.lines import Line2D
910
from more_itertools import always_iterable
1011

@@ -245,9 +246,11 @@ def labelLines(
245246
converter = ax.xaxis.converter
246247
else:
247248
converter = ax.xaxis.get_converter()
248-
if isinstance(converter, DateConverter):
249+
if isinstance(converter, (DateConverter, _SwitchableDateConverter)):
249250
xvals = [
250-
num2date(x).replace(tzinfo=ax.xaxis.get_units())
251+
x # type: ignore
252+
if isinstance(x, (np.datetime64, datetime))
253+
else num2date(x).replace(tzinfo=ax.xaxis.get_units())
251254
for x in xvals # type: ignore
252255
]
253256

0 commit comments

Comments
 (0)