我可以生成这样的十六进制图(代码取自 http://matplotlib.org/examples/pylab_examples/hexbin_demo.html )
import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
n = 100000
x = np.random.standard_normal(n)
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
xmin = x.min()
xmax = x.max()
ymin = y.min()
ymax = y.max()
plt.subplots_adjust(hspace=0.5)
plt.subplot(121)
plt.hexbin(x,y, cmap=cm.jet)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("Hexagon binning")
cb = plt.colorbar()
cb.set_label('counts')
plt.subplot(122)
plt.hexbin(x,y,bins='log', cmap=cm.jet)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("With a log color scale")
cb = plt.colorbar()
cb.set_label('log10(N)')
plt.show()
有没有办法用轴名称来标记 hexbin 的 x 轴和 y 轴?我希望“x-label”之类的内容显示在 x 轴数字下方,“ylabel”显示在 y 轴数字的左侧。这将是对颜色栏上标签的补充。
最佳答案
关于python - 是否可以在 matplotlib hexbin 图中命名 x 轴和 y 轴?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12397657/