第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

得到ValueError:'頂點(diǎn)'必須是形狀為Nx2的二維列表或數(shù)組,當(dāng)它是Nx2時(shí)?

得到ValueError:'頂點(diǎn)'必須是形狀為Nx2的二維列表或數(shù)組,當(dāng)它是Nx2時(shí)?

ibeautiful 2022-07-12 15:43:31
我正在嘗試使用此處概述的節(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)
查看完整描述

1 回答

?
炎炎設(shè)計(jì)

TA貢獻(xiàn)1808條經(jīng)驗(yàn) 獲得超4個贊

由于您想繪制一個集合,因此您希望verts成為每個多邊形的頂點(diǎn)列表。正如文檔所說,從技術(shù)上講,

verts是一個序列,( verts0, verts1, ...)其中verts_i是一個頂點(diǎn)的 xy 元組序列,或形狀 (nv, 2) 的等效 numpy 數(shù)組。

因此,如果您的集合只有一個多邊形,它仍然需要是一個包含單個條目的列表。在你的情況下

PolyCollection([verts])


查看完整回答
反對 回復(fù) 2022-07-12
  • 1 回答
  • 0 關(guān)注
  • 650 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號