首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >有没有可能在matplotlib的十六进制图中命名x和y轴?

有没有可能在matplotlib的十六进制图中命名x和y轴?
EN

Stack Overflow用户
提问于 2012-09-13 07:58:13
回答 1查看 922关注 0票数 1

我可以像这样生成一个六进制图(代码取自http://matplotlib.org/examples/pylab_examples/hexbin_demo.html)

代码语言:javascript
运行
复制
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轴数字的左侧。这将是对色条上标签的补充。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-13 08:55:04

您可以使用xlabelylabel matplotlib命令:

代码语言:javascript
运行
复制
plt.xlabel('x-label')
plt.ylabel('y-label')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12397657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档