A similar question has been raised :
how to force matplotlib to display only whole numbers on the Y axis
I am trying to do exactly the same for a bar plot. My problem is that the bar object does not unpack to fig, ax. Here is the code :
import matplotlib.pylab as plt
x = [0, 0.5, 1, 2, 3, 3.5, 4, 4.5, 5, 7.5, 8.5,9]
y = [1,2,2,3,1,2,2,2,2,1,1,0]
width = 0.5
plt.bar(x, y, width, color="pink")
plt.xlabel('score')
plt.ylabel('antall')
plt.show()
And the bar graph :
I would like to only display whole integers on y-axis and the opposite on the x-axis (i.e numbers 0 to 10 with 0.5 increment).