While joining the points given by scatterplot in matplotlib, I only want to get the natural fit, and not x-y , which becomes a zig-zag as shown below.
How can I do this in matpotlib ?
PS: I don't want fitting polynomial/regression line, just the regular natural line
from pylab import *
import matplotlib.pyplot as plt
//Generate some x-y data for yourself...
x=[key for key in my_dict.keys()]
y=[imp for imp in my_dict.values()]
xlim([min(x),max(x)])
ylim([min(y),max(y)])
plt.scatter(x,y)
I get :
On doing basic plot along with this, I get connected, but overlapping lines
plt.plot(x, y, '-o')
plt.show()
What I would like to have:
Related q/a but doesn't exactly fit my case
Fallback Alternatives - Fit a n-th degrees polynomial as here - Multivariate (polynomial) best fit curve in python?
Edit :- I tried the code below as suggested
[x, y] = zip(*sorted(zip(x, y), key=lambda x: x[0])) ###
plt.plot(x, y, '-o')
here's what I now get, butI am looking for something more smoother.