import numpy as np

x = np.arange(0, len(y_list), 1)

y = np.array(y_list)

fit_result = np.polyfit(x, y, 3)

print(fit_result)

import matplotlib.pyplot as plt

p1d = np.poly1d(fit_result)

y_values = p1d(x)  # 也可以用 yvals = np.polyval(fit_result, x)

plot1 = plt.plot(x, y, '*', label='original values')

plot2 = plt.plot(x, y_values, 'r', label='curve fit values')

plt.xlabel('x-axis')

plt.ylabel('y-axis')

plt.legend(loc=4)

plt.title('curve fitting')

plt.show()