griddata?scipy或matplotlib.mlab哪个软件包?
我运行了老师的代码,并弄错了它说不能从'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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论