三次样条得到平滑的 python 线曲线

cubic spline to get smooth python line curve

我需要使用三次样条在 python 中制作一条平滑线,我遵循了 scipy 教程,但有点困惑。我使用了以下代码:

import matplotlib.pyplot as plt
from scipy import interpolate

tck = interpolate.splrep(time, ca40Mass)
plt.semilogy(time,ca40Mass,label='$^{40}$Ca')
plt.xlabel('time [s]')
plt.ylabel('fallback mass [$M_\odot$]')
plt.xlim(20,60)
plt.ylim(1.0e-3, 2.0e-1)
plt.legend(loc=3)

我的剧情还是没有顺利,可能是我遗漏了什么,请帮我解决一下。我的情节输出是这样的:

您没有使用插值。

time_spline = numpy.linspace(min(time),max(time),1000)
ca40Mass_spline = interpolate.splev(time_spline, tck)
plt.semilogy(time_spline, ca40Mass_spline, label='$^{40}$Ca')