I am trying to plot a series of dates. Due to an incomplete data set the series have some None values, which cause an error.
This post deals with a similar issue successfully Python matplotlib - errorbar None values in series
But I have not been able to apply it to a list of datetime.date values.
My code is
import matplotlib.pyplot as plt
import datetime
import numpy as np
fig, ax1 = plt.subplots()
keys = ["a", "b", "c", "d"]
series_one = np.array(
[
datetime.date(2020, 11, 13),
datetime.date(2021, 2, 28),
datetime.date(2021, 3, 31),
datetime.date(2021, 4, 30),
]
)
series_two = np.array(
[
datetime.date(2020, 11, 13),
datetime.date(2021, 2, 28),
datetime.date(2021, 3, 31),
None,
]
)
series_three = np.array(
[
datetime.date(2020, 11, 13),
None,
datetime.date(2021, 3, 31),
datetime.date(2020, 2, 1),
]
)
ax1.scatter(series_one, keys)
ax1.scatter(series_two, keys)
ax1.scatter(series_three, keys)
The error message:
when using NoneType
AttributeError: 'NoneType' object has no attribute 'toordinal
when using float("NaN") istead of None.
AttributeError: 'float' object has no attribute 'toordinal'
