Error plotting with datetime and value using matplotlib in python
Matplotlib plots data in lists from left to right.

Hence, in the list x[idx] which is used in ax.plot(x[idx],y[idx], color="C0"), I assume that either the first element (according to x-axis) is in the back of the list, or the last element is at the beginning of the list.