我可以像这样生成一个六进制图(代码取自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()有没有办法用轴的名称来标记六面体的x轴和y轴?我希望像"x-label“这样的东西显示在x轴数字的下方,而"ylabel”则显示在y轴数字的左侧。这将是对色条上标签的补充。
发布于 2012-09-13 08:55:04
您可以使用xlabel和ylabel matplotlib命令:
plt.xlabel('x-label')
plt.ylabel('y-label')https://stackoverflow.com/questions/12397657
复制相似问题