I have an array of some data, where some of the values are missing
y = np.array([np.NAN, 45, 23, np.NAN, 5, 14, 22, np.NAN, np.NAN, 18, 23])
When I plot it, I have these NANs missing (which is expected)
fig, ax = plt.subplots()
ax.plot(y)
plt.show()
What I would like to have is a dotted line connecting the missing segments. For example in case of missing datapoint for 3, there should be a dotted line which connects existing points between 2 and 4, (the same for missing datapoints 7 and 8. If the datapoint is on the edge of the interval (datapoint 0) I would like to have a horizontal line connecting them (imagine previous/next datapoint the same as the available edge).
The questions I saw here ask how to remove these empty segments (not what I want). I can solve it by creating another array which will have missing values interpolated and all other values NAN, but it looks to complex to me.
Because this looks like a common case, I hope there is an easier approach.