【发布时间】:2020-06-03 04:16:40
【问题描述】:
请问如何平滑这条蓝线?
import numpy as np
from matplotlib import pyplot as plt
a = [0.5365140382771445, 0.5214107372135204, 0.49844631119258076, 0.4681910992517213, 0.4310817214420628, 0.3882500155177606, 0.340292343154754, 0.2880252732908801]
b = [0.7416012836460293, 0.697385422521102, 0.6561831711375956, 0.6187959941327967, 0.585900754784896, 0.5586375446776617, 0.537388969490203, 0.5229339200070606]
time_fit = np.arange(len(b))
fitx = np.polyfit(time_fit, a, 2)
fity = np.polyfit(time_fit, b, 2)
x_fit = np.poly1d(fitx)
y_fit = np.poly1d(fity)
plt.figure(figsize=(8, 8))
plt.plot(x_fit, y_fit, c='red')
plt.plot(a, b, c = 'blue')
plt.show()
我是否用错误的多项式拟合它?
【问题讨论】:
标签: python-3.x matplotlib smoothing