AttributeError: 'numpy.ndarray' object has no attribute 'step'
我要获取三维网格,并使用以下命令:
1 2 3 4 5 | x = np.linspace(-10,10,100) y = np.linspace(-10,10,100) z = np.linspace(-10,10,100) X,Y,Z = np.mgrid[x, y, z] |
这样的错误出现了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | AttributeError Traceback (most recent call last) in () 6 7 ----> 8 X,Y,Z = np.mgrid[x, y, z] 9 10 #X,Y,Z = np.mgrid[-10:10, -10:10, -10:10] ~/Desktop/PyProjects/Phys/env/lib/python3.6/site-packages/numpy/lib/index_tricks.py in __getitem__(self, key) 165 typ = int 166 for k in range(len(key)): --> 167 step = key[k].step 168 start = key[k].start 169 if start is None: AttributeError: 'numpy.ndarray' object has no attribute 'step' |
号
我知道我可以用这个表格生成网格
1 | X,Y,Z = np.mgrid[-10:10, -10:10, -10:10] |
但它对我来说不是移动的
尝试np.meshgrid()而不是mgrid:
1 | X, Y, Z = np.meshgrid(x, y, z) |