我正在尝试使用此处概述的节点坐标和连接性来绘制网格:关联我有一个存储在 numpy 数组中的节点坐标列表(xy 和 z 坐标)我将 x 和 y 定义为:x = coords[:,0]y = coords[:,1]我在一个 numpy 数组中有节点连接connectivity,它有连接在一起的坐标的 ID 号然后,按照他们的示例,执行以下操作:xy = np.c_[x,y]verts= xy[connectivity]pc = matplotlib.collections.PolyCollection(verts)我得到这个错误: File "C:\Users\deden\AppData\Local\Continuum\anaconda3\envs\dhi\lib\site-packages\matplotlib\path.py", line 130, in __init__ "'vertices' must be a 2D list or array with shape Nx2")ValueError: 'vertices' must be a 2D list or array with shape Nx2去检查:xy.shape[1]是 2 并且 xy.ndim是 2回溯文件中的第 130 行是:vertices = _to_unmasked_float_array(vertices)if vertices.ndim != 2 or vertices.shape[1] != 2: raise ValueError( "'vertices' must be a 2D list or array with shape Nx2")并_to_unmasked_float_array(vertices)调用:def _to_unmasked_float_array(x): """ Convert a sequence to a float array; if input was a masked array, masked values are converted to nans. """ if hasattr(x, 'mask'): return np.ma.asarray(x, float).filled(np.nan) else: return np.asarray(x, float)我不明白为什么如果verts.shape[1]and verts.ndim= 2我会收到此错误消息也np.asarray(verts, float).shape[1]和np.asarray(verts, float).ndim也是 2到底他妈发生了什么?我错过了什么吗?非常感谢任何人的帮助还..verts.shape返回(181660, 2)
添加回答
举报
0/150
提交
取消