在 Pandas plot() 中指定 y_label
Specifying y_label in Pandas plot()
我想在下面的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也没有。我该如何解决?
这应该有效:
ax = row.value_counts().reindex().plot(kind='bar')
ax.set_ylabel("something")
我想在下面的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也没有。我该如何解决?
这应该有效:
ax = row.value_counts().reindex().plot(kind='bar')
ax.set_ylabel("something")