Гладкая линия ndarray - PullRequest
       23

Гладкая линия ndarray

0 голосов
/ 18 февраля 2020

Как сгладить эту линию, пожалуйста?

У меня есть данные:

print(x, y)
print(type(x), type(y))
 [0.47783251 0.47783251 0.50765082 0.52907554 0.54089849 0.54318757
 0.53651404 0.52141074 0.49844631 0.4681911  0.43108172 0.38825002
 0.34029234 0.28802527 0.23297804 0.17570859 0.11816758]
 [0.97044335 0.97044335 0.92906509 0.88319329 0.83547025 0.78792294
 0.74160128 0.69738542 0.65618317 0.61879599 0.58590075 0.55863754
 0.53738897 0.52293392 0.51577606 0.51612184 0.5240563 ]
<class 'numpy.ndarray'> <class 'numpy.ndarray'>

, что дает цифру

enter image description here

Я пытался:

from scipy import interpolate
plt.figure(figsize=(8, 8))
tck = interpolate.splrep(x, y, s=0)
xnew = np.arange(0.1, 0.6, 1/1000)
ynew = interpolate.splev(xnew, tck, der=0)
plt.plot(xnew, ynew, c='red')
plt.show()

и

from scipy.interpolate import interp1d
plt.figure(figsize=(8, 8))
xnew = np.linspace(0.1, 0.6, num=41, endpoint=True)
f = interp1d(x, y)
f2 = interp1d(x, y, kind='cubic')
plt.plot(f2(xnew), '-')
plt.show()

Однако, это не подходящая процедура для этого типа данных, не так ли?

...