相关疑难解决方法(0)

将标题添加到pandas hist图的集合中

我正在寻找关于如何在由pandas df.hist()命令生成的直方图集合顶部显示标题的建议.例如,在下面的代码生成的直方图图块中,我想在图的顶部放置一个通用标题(例如"我的直方图图集"):

data = DataFrame(np.random.randn(500).reshape(100,5), columns=list('abcde'))
axes = data.hist(sharey=True, sharex=True)
Run Code Online (Sandbox Code Playgroud)

我已尝试在hist命令中使用title关键字(即title ='我的直方图图集'),但这不起作用.

以下代码通过向其中一个轴添加文本(在ipython笔记本中)可以正常工作,但有点像kludge.

axes[0,1].text(0.5, 1.4,'My collection of histogram plots', horizontalalignment='center',
               verticalalignment='center', transform=axes[0,1].transAxes)
Run Code Online (Sandbox Code Playgroud)

有没有更好的办法?

python title histogram pandas

25
推荐指数
4
解决办法
4万
查看次数

标签 统计

histogram ×1

pandas ×1

python ×1

title ×1