没有为 pandas boxplot (groupby) 设置标题

新手上路,请多包涵

当绘制按另一列分组的 pandas 箱线图时,pandas 会自动为绘图添加标题,即“Boxplot grouped by ….”。有没有办法删除它?我尝试使用

suptitle('')

根据 Pandas:一列基于另一列的箱线图

但这似乎不起作用。我正在使用最新的 pandas (0.13.1) 版本。

原文由 user308827 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1k
2 个回答

确保你的呼叫 suptitle('') 在右图中。

 In [23]: axes = df.boxplot(by='g')

In [24]: fig = axes[0][0].get_figure()

In [25]: fig.suptitle('')
Out[25]: <matplotlib.text.Text at 0x109496090>

原文由 TomAugspurger 发布,翻译遵循 CC BY-SA 3.0 许可协议

我有同样的问题。结束使用 这个解决方案

import matplotlib.pyplot as plt
# df is your dataframe
df.boxplot(column='value', by='category')
title_boxplot = 'awesome title'
plt.title( title_boxplot )
plt.suptitle('') # that's what you're after
plt.show()

原文由 nick 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题