次のように2次元ヒストグラムを作成しています:
import matplotlib as plt
import numpy as np
hist,xedges,yedges = np.histogram2d(x,y,bins=[50,150],range=[[0,50],[0,150]])
Hmasked = np.ma.masked_where(hist==0,hist) # Mask pixels with a value of zero
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1] ]
plt.imshow(Hmasked.T,extent=extent,interpolation='nearest',origin='lower')
plt.show()
これには、x に 50 個のビン、y に 150 個のビンがあります。結果のプロットは、x 方向が狭く、y 方向が高くなっています。x のビンがより広く表示されるように、x のプロットを引き伸ばすにはどうすればよいですか? 通常の図の縦横比に自動的に引き伸ばすコードがあれば、それが最適です。