【发布时间】:2021-07-28 17:50:37
【问题描述】:
我尝试使用以下代码绘制具有非常不同范围的数据的二维直方图。但是,由于数据范围不同,x 数据重叠如下图。是否有任何解决方案可以绘制具有相同轴长的 x 和 y 数据?
import numpy as np
from matplotlib import pyplot as plt
plt.clf()
x = np.random.randint(low=0, high=10, size=8873)
y = np.random.randint(low=100000,high=600000, size=8873)
heatmap, xedges, yedges = np.histogram2d(x, y, bins=50)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
plt.imshow(heatmap.T, extent=extent, origin='lower')
plt.show()
【问题讨论】:
-
plt.imshow(... aspect='auto')
标签: python matplotlib heatmap