File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 3
3
4
4
import matplotlib .pyplot as plt
5
5
import numpy as np
6
+ from datetime import datetime
6
7
from matplotlib .container import ErrorbarContainer
7
- from matplotlib .dates import DateConverter , num2date
8
+ from matplotlib .dates import DateConverter , num2date , _SwitchableDateConverter
8
9
from matplotlib .lines import Line2D
9
10
from more_itertools import always_iterable
10
11
@@ -245,9 +246,11 @@ def labelLines(
245
246
converter = ax .xaxis .converter
246
247
else :
247
248
converter = ax .xaxis .get_converter ()
248
- if isinstance (converter , DateConverter ):
249
+ if isinstance (converter , ( DateConverter , _SwitchableDateConverter ) ):
249
250
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 ())
251
254
for x in xvals # type: ignore
252
255
]
253
256
You can’t perform that action at this time.
0 commit comments