我制作了一个二维柱状图,如下所示:
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上是高的。a如何在x中展开图,以便x中的箱子看起来更宽?如果有代码可以自动将其拉伸到正常的图形纵横比,那将是最佳选择。在
相关问题 更多 >
编程相关推荐