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

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

如何解決 Matplotlib 中的鋸齒狀網(wǎng)格?

如何解決 Matplotlib 中的鋸齒狀網(wǎng)格?

慕標(biāo)琳琳 2023-02-07 13:49:57
我有一個問題需要你的幫助?,F(xiàn)在我有一個網(wǎng)格數(shù)據(jù)。它由多個不同的值組成。結(jié)構(gòu)如下圖所示。 實際圖形事實上,我想要得到的圖形應(yīng)該是由平滑的填充曲面組成的。如下所示。 我想要的圖形我提供了一個特定的數(shù)據(jù)集。請參考。 樣本數(shù)據(jù)集。這個數(shù)據(jù)集是“surfer”軟件定義的asc格式。您可以使用“pykrige”來閱讀。使用以下代碼進(jìn)行渲染import sysimport matplotlib.pyplot as pltimport pykrige.kriging_tools as ktdef func(cmd):       ascFile = cmd[1]   ascFileContent = kt.read_asc_grid(ascFile)   Z = ascFileContent[0]   X = ascFileContent[1]   Y = ascFileContent[2]   print(Z)   fig = plt.figure()       ax = fig.add_subplot()   contour = plt.contourf(X,Y,Z)   #contour = plt.pcolormesh(X,Y,Z)   plt.show()if __name__ == "__main__":   cmd=["CONTOUR_KYZQ"]   #gridFile   cmd.append(r"D:\out.grd")   func(cmd)我使用了各種方法,例如 pcolormesh、contourf。生成的圖形呈鋸齒狀。我怎么解決這個問題。請幫我。多謝。
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻(xiàn)1818條經(jīng)驗 獲得超11個贊

用于scipy.ndimage.zoom平滑圖像。這是我對數(shù)字 5 使用平滑,但您可以嘗試其他數(shù)字。


import matplotlib.pyplot as plt

import pykrige.kriging_tools as kt

import scipy.ndimage


ascFileContent = kt.read_asc_grid("out.grd")

Z = ascFileContent[0]

X = ascFileContent[1]

Y = ascFileContent[2]


fig = plt.figure()    

plt.rcParams['figure.figsize'] = [20, 14]



new_z = scipy.ndimage.zoom(Z, 5)


contour = plt.contourf(np.linspace(X[0], X[-1], len(X) * 5), 

                       np.linspace(Y[0], Y[-1], len(Y) * 5), 

                       new_z)



plt.show()

如果您放大特定區(qū)域(如此代碼片段所示),您會注意到您的數(shù)據(jù)本質(zhì)上是“方格的”。所以即使平滑了,也有一些區(qū)域看起來非常像網(wǎng)格(見下文)。


ascFileContent = kt.read_asc_grid("out.grd")

Z = ascFileContent[0]

X = ascFileContent[1]

Y = ascFileContent[2]


fig = plt.figure()    

plt.rcParams['figure.figsize'] = [20, 14]

ZOOM_FACTOR = 5


new_z = scipy.ndimage.zoom(Z, ZOOM_FACTOR)


contour = plt.contourf(np.linspace(X[0], X[-1], len(X) * ZOOM_FACTOR), 

                       np.linspace(Y[0], Y[-1], len(Y) * ZOOM_FACTOR), 

                       new_z)


plt.xlim((106, 107))

plt.ylim((24, 26))


plt.show()

http://img1.sycdn.imooc.com//63e1e6be0001229b11770793.jpg

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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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