【问题标题】:How to remove automated chart titles generated by Pandas如何删除 Pandas 生成的自动图表标题
【发布时间】:2017-09-08 10:46:20
【问题描述】:

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

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')

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

我可以摆脱 1 使用:

bp.get_figure().suptitle('')

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

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

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

提前感谢您的帮助!

【问题讨论】:

  • set_ylabel('')?
  • 对我没有任何改变。它应该通过什么来进行? f.e. bp.get_figure().gca().set_ylabel("")

标签: python pandas matplotlib jupyter-notebook


【解决方案1】:

您还需要通过以下方式去掉坐标轴上的标题:

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

如果你也想去掉 [country] 部分:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    相关资源
    最近更新 更多