Reputation: 137
I am trying to plot this curve, and am a little confused on why it looks the way that it does. I would like to plot the curve seen below, but I don't want the lines in the middle and can't figure out why they're there. Could it be because there are 0's in the middle of the vector representing the y values?
Upvotes: 1
Views: 1127
Reputation: 474
It is already late but I hope it may help to someone. Taken from that answer why my curve fitting plot using matplotlib looks obscured?
You need to sort your X
's in ascending order and then use it in plot
function. Please bear in mind x and y pairs should be preserved to have correctly drawn curve.
import numpy as np
sorted_indexes = np.argsort(X)
X = X[sorted_indexes]
y = y[sorted_indexes]
Upvotes: 0
Reputation: 10650
This is just from my phone, so apologies if the formatting is off...
This is happening because you have data with zeros in it. If you want to prune them out in some way, then either you can do it on the reads, or you can sort the data. Something like this should suffice:
x, y = sorted(zip(x, y))
Upvotes: 2