我正在尝试使用此处概述的节点坐标和连通性绘制网格:
我有一个存储在numpy数组中的节点坐标列表(x y和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]
和verts.ndim
= 2,我不明白为什么会收到此错误消息,>
也是np.asarray(verts, float).shape[1]
和np.asarray(verts, float).ndim
也是2
到底发生了什么?我错过了什么吗?非常感谢任何人的帮助
也..
verts.shape
返回
(181660, 2)
我正在尝试使用此处概述的节点坐标和连通性绘制网格:链接我有一个存储在numpy数组中的节点坐标列表(xy和z坐标),我将x和y定义为:x = ...] >
由于要绘制集合,所以希望verts
是顶点的列表[[每个多边形