1

I have a very simple stacked bar plot. I have grouped data

df=pd.crosstab(pd.cut(df_main['AMOUNT'], 10), df_main['Status'])
df.plot.bar(stacked=True)

All I want is to change the tick labels in a range form. Right now label are coming up like [108742.081, 2206696.838], I want them to come up like 108,742 to 2,206,696.

j__carlson
  • 1,346
  • 3
  • 12
  • 20

1 Answers1

0

Tick labels can be explicitly defined as such:

df=pd.crosstab(pd.cut(df_main['AMOUNT'], 10), df_main['Status'])
df.plot.bar(stacked=True, xticks=list_of_X_values, yticks=list_of_Y_values)

You can use it with range like this:

df=pd.crosstab(pd.cut(df_main['AMOUNT'], 10), df_main['Status'])
df.plot.bar(stacked=True, yticks=list(range(108742, 2206696, 1000)))

Edit: If you need to auto define the endpoint you can use this

df.plot.bar(stacked=True, yticks=list(range(min(df['y_colname']), max(df['y_colname']), 1000)))
j__carlson
  • 1,346
  • 3
  • 12
  • 20