如何删除 Pandas 生成的自动图表标题

mic*_*alk 6 python matplotlib pandas jupyter-notebook

我使用以下代码生成了一个箱线图:

import pandas as pd
import random

country = ['A' for z in range(1,6)] + [ 'B' for z in range(1,6)]
sales = [random.random() for z in range(1,11)]
data =pd.DataFrame({'country':country, 'sales':sales})

bp=data.boxplot(by='country')
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Pandas 生成图表的自动标题。1. '按国家分组的箱线图' 2. '销售额'

我可以摆脱 1 使用:

bp.get_figure().suptitle('')
Run Code Online (Sandbox Code Playgroud)

但我不知道如何摆脱第二个“销售”

我一整天都在努力搜索堆栈溢出,但似乎没有任何效果。

我正在将 Python 3.6.1 与 Conda 一起使用。我在 Jupiter notebook 中运行的代码。

预先感谢您的帮助!

Lou*_*ies 9

您还需要通过以下方式摆脱轴上的标题:

bp.get_figure().gca().set_title("")

如果你也想摆脱 [country] 部分:

bp.get_figure().gca().set_xlabel("")