Home > Enterprise >  Is there a way to change scale of y axis in python plot?
Is there a way to change scale of y axis in python plot?

Time:04-11

Currently i am able to generate this plot to calculate number of people using applications, but i am getting y axis values as in decimals ,where in people cannot be in decimals. how can i change this ?

df_pivot=pd.pivot_table(df_removed1,index=['Module'],columns=['Date'], aggfunc='size').plot(kind='bar',grid=True)
plt.xticks(weight='bold')
plt.xlabel(App_req,size="25",weight='bold')
plt.title(grph_title)

this is the code i am using to plot graph for my data

current output

CodePudding user response:

You can try using plt.set_yticks()

docs here: https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.set_yticks.html

CodePudding user response:

You can try to give yticks() the integers generated by range():

plt.yticks(range(0,2))

Otherwise you can try:

from matplotlib.ticker import MaxNLocator
plt.yaxis.set_major_locator(MaxNLocator(integer=True))
  • Related