Home > Software design >  Specifying y_label in Pandas plot()
Specifying y_label in Pandas plot()

Time:11-15

I want to specify y_label in the following Pandas plot function, but it seems that the syntax is not correct.

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

because the error is

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

If I use row.value_counts().reindex().plot().bar(), there is no problem, but there no y_label too. How can I fix that?

CodePudding user response:

This should work:

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