【问题标题】:Specifying y_label in Pandas plot()在 Pandas plot() 中指定 y_label
【发布时间】:2021-12-25 22:14:56
【问题描述】:

我想在下面的 Pandas 绘图函数中指定 y_label,但似乎语法不正确。

row = df.iloc[0].astype(int)
row.value_counts().reindex().plot(ylabel='something').bar()

因为错误是

bar() missing 2 required positional arguments: 'x' and 'height'

如果我使用row.value_counts().reindex().plot().bar(),没有问题,但也没有y_label。我该如何解决?

【问题讨论】:

  • row.value_counts().reindex().plot(kind='bar') 工作吗?
  • @JoshFriedlander:是的,它有效。

标签: pandas plot


【解决方案1】:

这应该可行:

ax = row.value_counts().reindex().plot(kind='bar')
ax.set_ylabel("something")

【讨论】:

  • 也可以row.value_counts().reindex().plot(kind='bar',ylabel='something') 工作
猜你喜欢
  • 1970-01-01
  • 2021-07-17
  • 2020-08-12
  • 2015-08-18
  • 1970-01-01
  • 2013-08-25
  • 2015-06-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多