三次插值不显示,但线性插值显示?

2024-04-25 10:11:57 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我做了一些数据点并绘制了它们。然后,我想插值并绘制它的三次函数。然而,当我绘图时,只有3个函数出现。如何使所有功能都显示出来?另外,当我绘制插值线性函数时,所有的线都显示得很好。你知道吗

xnew = np.linspace(0.0414, 1.0414, 10000)

z, mass1, mass2, mass3, mass4, mass5, mass6, mass7 = np.loadtxt("BHMF_bluemassfinal.dat", usecols = [0,1,2,3,4,5,6,7], unpack = True)
axes[0].plot(z, mass1,'bo')
axes[0].plot(z, mass2, 'bo')
axes[0].plot(z, mass3, 'bo')
axes[0].plot(z, mass4, 'bo')
axes[0].plot(z, mass5, 'bo')
axes[0].plot(z, mass6, 'bo')
axes[0].plot(z, mass7, 'bo')
axes[0].plot(xnew, fb1(xnew), 'k')
axes[0].plot(xnew, fb2(xnew), 'k')
axes[0].plot(xnew, fb3(xnew), 'k')
axes[0].plot(xnew, fb4(xnew), 'k')
axes[0].plot(xnew, fb5(xnew), 'k')
axes[0].plot(xnew, fb6(xnew), 'k')
axes[0].plot(xnew, fb7(xnew), 'k')

z, mass1, mass2, mass3, mass4, mass5, mass6, mass7 = np.loadtxt("BHMF_greenmassfinal.dat", usecols = [0,1,2,3,4,5,6,7], unpack = True)
axes[1].plot(z, mass1, 'go')
axes[1].plot(z, mass2, 'go')
axes[1].plot(z, mass3, 'go')
axes[1].plot(z, mass4, 'go')
axes[1].plot(z, mass5, 'go')
axes[1].plot(z, mass6, 'go')
axes[1].plot(z, mass7, 'go')
axes[1].plot(xnew, fg1(xnew), 'k')
axes[1].plot(xnew, fg2(xnew), 'k')
axes[1].plot(xnew, fg3(xnew), 'k')
axes[1].plot(xnew, fg4(xnew), 'k')
axes[1].plot(xnew, fg5(xnew), 'k')
axes[1].plot(xnew, fg6(xnew), 'k')
axes[1].plot(xnew, fg7(xnew), 'k')

enter image description here


Tags: 函数goplotnp绘制boaxesxnew
1条回答
网友
1楼 · 发布于 2024-04-25 10:11:57

最后,我意识到一些数据点数学.nan. 他们不允许插值。你知道吗

我必须采取我的主要文件,并削减成不同的单独文件,其中红移垃圾箱将匹配我的大规模垃圾箱。因此,我带走了数学.nan我可以做插值。你知道吗

我的解决方案相当愚蠢。如果有人能提出一个更有效的解决方案,请随时张贴它无论如何。你知道吗

相关问题 更多 >