data = np.polynomial.polynomial.polyval(x, [0, 2, 1, -2, -3, 2.6, -0.4])
noise = np.random.normal(0, 0.1, 250)
noisy_data = data + noise
f = splrep(x, noisy_data, k=5, s=3)
plt.plot(x, noisy_data, label='noisy data')
plt.plot(x, splev(x, f), label='fitted')
plt.plot(x, splev(x, f, der=1) / 10, label='1st derivative')
plt.hlines(0, 0, 2)
plt.legend(loc=0)
plt.show()
Gradient in noisy data, python