I would like to display the smoothed curve between two lists.
The two lists have values that they correspond to different values on the other list. The values of the two lists are linked by their indices.
Of course the size of the two lists is identical.
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import make_interp_spline
list1 = [0.9117647058823529, 0.9117647058823529, 0.9090909090909091,..]
list2 = [0.32978723404255317, 0.34065934065934067, 0.3448275862068966,..]
#plt.plot(list1, list2) works well
x = np.array(list1)
y = np.array(list2)
xnew = np.linspace(x.min(), x.max(), 300)
spl = make_interp_spline(x, y)
y_smooth = spl(xnew)
plt.plot(xnew, y_smooth)
gives me ValueError: Expect x to be a 1-D sorted array_like.
When I use interp1d
rather than make_interp_spline
I have ValueError: Expect x to not have duplicates
How to display the smoothed curve without losing any point? Thank you for your attention.