Q:

How to change ticks on a histogram? (matplotlib)

I have a histogram with only a few values. As a result, the x axis ticks are decimals:

How can I make it 1,2,3,4,5?

A:

You can use matplotlib.pyplot.xticks to set the locations of the x-axis tick marks.
Without the code used to generate the question's histogram, I resorted to creating data to produce a similar histogram. In this first example, we have a histogram with the default tick marks.
from pylab import hist, show

x = [1.1]*29 + [2]*7 + [3.2]*3 + [5]
hist(x)
show()

The objective is to have tick marks at 1, 2, 3, 4, and 5, and the next example does this by using xticks.
from pylab import hist, show, xticks

x = [1.1]*29 + [2]*7 + [3.2]*3 + [5]
hist(x)
xticks(range(1, 6))
show()

