enter image description here I am trying to plot a bar graph on powerBi using python and i am expecting values on y-axis after the interval of 10 for example 0-10,10-20 upto 100. But in actual it is showing after interval of 25, like 0-25, 26-50 and so on
import matplotlib.pyplot as plt
ax=plt.gca()
#dataset.plot(kind='bar',x='Day',y='Feed_Req_to_Standard',ax=ax)
dataset.plot(kind='bar',x='Day',y=['Feed_%Diff_From_Stand','Feed_Req_to_Standard'], color=['red','green'],ax=ax)
plt.ylim(bottom= -100, top= 100)
plt.xlabel('Days')
plt.show()
You can set the tick locations and labels on the y axis using the function matplotlib.axes.Axes.set_yticks()
. If you want to take a closer look, here is the documentation . Applied to your problem, it would probably be applied like this (note I haven't tested it though as I don't have access to your data).
import matplotlib.pyplot as plt
from matplotlib.axes import Axes
spacing = 10
ticks = [spacing*i for i in range(5)] # gets ticks values
Axes.set_yticks(ticks)
ax=plt.gca()
dataset.plot(kind='bar',x='Day',y=['Feed_%Diff_From_Stand','Feed_Req_to_Standard'], color=['red','green'],ax=ax)
plt.ylim(bottom= -100, top= 100)
plt.xlabel('Days')
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.