File tree 1 file changed +16
-5
lines changed
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -283,11 +283,22 @@ def labelLines(
283
283
else :
284
284
converter = ax .xaxis .get_converter ()
285
285
time_classes = (_SwitchableDateConverter , DateConverter , ConciseDateConverter )
286
- if isinstance (converter , time_classes ):
287
- xvals = [
288
- num2date (x ).replace (tzinfo = ax .xaxis .get_units ())
289
- for x in xvals # type: ignore
290
- ]
286
+ if xvals is None :
287
+ raise ValueError (
288
+ "xvals must be a tuple of two floats or a list of floats."
289
+ f"Got { xvals } instead."
290
+ )
291
+ elif isinstance (converter , time_classes ):
292
+ xvals_dates = []
293
+ for x in xvals :
294
+ if isinstance (x , datetime ):
295
+ x_datetime = x
296
+ elif isinstance (x , np .datetime64 ):
297
+ x_datetime = x .astype (datetime )
298
+ else :
299
+ x_datetime = num2date (x )
300
+ xvals_dates .append (x_datetime .replace (tzinfo = ax .xaxis .get_units ()))
301
+ xvals = xvals_dates
291
302
292
303
txts = []
293
304
try :
You can’t perform that action at this time.
0 commit comments