How to create a bar chart/histogram with bar per discrete value?

I am trying to create a histogram that will show the amount of ratings per value in a discrete star ratings (1-5).
There should be a bar per value, and in the x-axis the only numbers to be shown are [1,2,3,4,5] underneath each bar (centered).

I tried setting the amount of bins to 5 or their range to be from 0-7, but that creates bars that span across values (as in the image supplied)

enter image description here

This is the code I have 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")

Best answer

You can use the plot(kind='bar') method:

stars = Series(randint(1, 6, size=100))
vc = stars.value_counts().sort_index()
ax = vc.plot(kind='bar')
fig = ax.get_figure()
fig.autofmt_xdate()

to get:

enter image description here

EDIT #1: To show them as proportions just divide by the sum

vc /= float(vc.sum())
assert vc.sum() == 1

to get:

enter image description here

EDIT #2: To show them as percentages divide by the sum as above and use the format spec mini-language to format the y-axis tick labels

new_labels = ['{0:.0%}'.format(float(x.get_text())) for x in ax.get_yticklabels()]
ax.set_yticklabels(new_labels)

to get:

enter image description here