I am trying to plot the frequency of integers in a large list of number in a large range. More specifically:
ints = np.random.random_integers(0,1440,15000)
ints is a long list of integers with values between 0 and 1440. Next I want to plot a histogram that will visualize the frequencies. To that end, I use something like:
fig_per_hour = plt.figure()
per_hour = fig_per_hour.add_subplot(111)
counts, bins, patches = per_hour.hist(
ints, bins = np.arange(0,1441), normed = False, color = 'g',linewidth=0)
plt.show()
But I face two problems:
- An annoying gap at the right end of the x-axis. Although I specify the right(?) amount of bins, the plot doesn't reflect it.
- Due to the large range from which the ints are sampled, each bar is very thin, and hard to distinct. Is it possible to stretch the x-axis so the bars will be wider? The reason is that I want to annotate the x-axis and some of the bars.
For reference, here's the output I have so far:



plt.xlimits(min,max)to make sure the x-axis limits are within your range. andplt.hist(data, bins = range(min,max+binwidth,binwidth))to make sure the bins are equally distributed