griddata?scipy或matplotlib.mlab哪个软件包?

发布于 2025-01-30 19:59:46 字数 788 浏览 2 评论 0原文

我运行了老师的代码,并弄错了它说不能从'matplot.mlab'导入'griddata'的名称,然后我从scipy import import griddata'编码,然后得到'griddata()获得了意外的关键字参数'Interpp',因为那里是因为那里是'z = griddata(x,y,z,xi,yi,interp ='linear')'的行。 我不知道如何修改此代码

是代码:

from matplotlib import cm
from matplotlib.mlab import griddata  # i used 'from scipy.interpolate import griddata' , and it could work ,but showed error '

x = np.genfromtxt(sys.argv[2], usecols=(0))
y = np.genfromtxt(sys.argv[2], usecols=(1))
z = np.genfromtxt(sys.argv[2], usecols=(2))

xi = np.linspace(x.min(), x.max(), 1000)
yi = np.linspace(y.min(), y.max(), 1000)
zi = griddata(x, y, z, xi, yi, interp='linear')

当我运行时,它会出现错误'griddata()获得了意外的关键字参数'Interp'。我将“ Interp”更改为“方法”,因为scipy.doc显示它可以使用(方法='linear'),但是它也有错误'griddata()获得了意外的关键字参数'方法'。

I ran my teacher's code and got wrong that it said cannot import name 'griddata' from 'matplot.mlab', i coded then 'from scipy import griddata' and it got 'griddata() got an unexpected keyword argument 'interp' because there is a line 'z = griddata(x,y,z,xi,yi,interp='linear')'.
i don't know how to modify this code

here is the code :

from matplotlib import cm
from matplotlib.mlab import griddata  # i used 'from scipy.interpolate import griddata' , and it could work ,but showed error '

x = np.genfromtxt(sys.argv[2], usecols=(0))
y = np.genfromtxt(sys.argv[2], usecols=(1))
z = np.genfromtxt(sys.argv[2], usecols=(2))

xi = np.linspace(x.min(), x.max(), 1000)
yi = np.linspace(y.min(), y.max(), 1000)
zi = griddata(x, y, z, xi, yi, interp='linear')

when i ran it got error 'griddata() got an unexpected keyword argument 'interp'. I changed ' interp' to 'method' because scipy.doc shows it can use (method='linear'),but it also got error 'griddata() got an unexpected keyword argument 'method'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文