1

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

我的情节仍然没有顺利,也许我错过了一些东西,请帮我解决这个问题。我的绘图输出是这样的:

在此处输入图像描述

4

1 回答 1

2

您没有使用插值。

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')
于 2016-08-20T20:18:48.397 回答