Reputation: 315
I've drawn a plot of 20 points on matplotlib However, applying a '-o' parameter on the plot causes the plots to be connected in a weird order. I would like it connected along the x axis (lowest x to highest x)
It currently looks like this
This is what it looks like with '-o'
Is there a way to force matplotlib to plot in increasing order of x values?
Upvotes: 0
Views: 863
Reputation: 22544
Yes.
Sort the points in increasing order of x
-coordinates before giving those points to matplotlib, which simply connects the points in the order you give them to matplotlib.
(We could help you more if you show us the code, perhaps simplified, that gave you that bad example plot.)
Upvotes: 3