我正在嘗試使用此處概述的節(jié)點(diǎn)坐標(biāo)和連接性來繪制網(wǎng)格:關(guān)聯(lián)我有一個存儲在 numpy 數(shù)組中的節(jié)點(diǎn)坐標(biāo)列表(xy 和 z 坐標(biāo))我將 x 和 y 定義為:x = coords[:,0]y = coords[:,1]我在一個 numpy 數(shù)組中有節(jié)點(diǎn)連接connectivity,它有連接在一起的坐標(biāo)的 ID 號然后,按照他們的示例,執(zhí)行以下操作: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)調(diào)用: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到底他媽發(fā)生了什么?我錯過了什么嗎?非常感謝任何人的幫助還..verts.shape返回(181660, 2)
得到ValueError:'頂點(diǎn)'必須是形狀為Nx2的二維列表或數(shù)組,當(dāng)它是Nx2時(shí)?
ibeautiful
2022-07-12 15:43:31