I'm trying to create a histogram that displays the number of ratings for the value in the discrete values โโof the star (1-5). There must be a bar value by a value, and along the x axis the only numbers to be shown are [1,2,3,4,5] under each bar (in the center).
I tried setting the number of bins to 5 or their range from 0 to 7, but this creates stripes that span the values โโ(as in the image below)

This is the code I tried (pandas and numpy):
df.stars.hist()
and
hist, bins = np.histogram(x1, bins=5) ax.bar(bins[:-1], hist.astype(np.float32) / hist.sum(), width=(bins[1]-bins[0]), color="blue")
source share