我需要使用三次样条在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')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句