0
我試圖在python中使用pcolor繪製矩陣。這是我的代碼,但它不起作用。你能告訴我如何繪製矩陣?!Python中的Pcolor數據圖
Matrix = np.zeros((NumX, NumY))
for i in range(NumX):
for j in range(NumY):
Matrix[i][j] = Data[i*NumY+j+1]
# Set up a regular grid of interpolation points
xi = np.arange(0, NumX*1.5, 1.5)
yi = np.arange(0, NumY*1.5, 1.5)
X, Y = np.meshgrid(xi, yi)
intensity = np.array(Matrix)
plt.pcolormesh(X, Y, Matrix)
plt.colorbar()
plt.show()
這是錯誤:
TypeError: Dimensions of C (22, 30) are incompatible with X (22) and/or Y (30); see help(pcolormesh)