我需要使用三次样条在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')