I'm trying to plot some timelines including NaN's with pyplot (see sample code). The problem is, that when there's a NaN, pyplot doesn't draw a line between the points before and after the NaN. Is there any solution to change this behaviour? I don't want to fill in any computed data points instead of the NaN. Deleting the NaN is not an option either, because that would result in the x- and y-lists having different lengths.
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
y = [1, 2, 5, 4, 7, "nan", 4, 2, 5, 4, 4, 1]
plt.show(plt.plot(x, y, 'o-', linewidth = 0.5))
Thanks a lot, Julian
"nan"i.e a string? Or are they actuallyNaN?