0

I would like to make a histogram with binned data with Python, but I didn't figure out how to make one. I didn't find any documentation (or I Googled wrong), but I've tried this:

import pylab as plb

a = [1, 2, 3, 4, 5, 6] # my histogram bins
b = [1, 4, 6, 1, 3, 7] # my data

plb.hist(b, bins = a)
plb.show()

and related alternatives, and of course it doesn't work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user4050567
  • 87
  • 10

1 Answers1

0

The example you give runs just fine on my PC, granted it is not looking very nice. A good place to search for recipes common graphs is the gallery of Matplotlib: http://matplotlib.org/gallery.html. If you want to get more information about what arguments the functions use, you can take a look at the documentation (http://matplotlib.org/api/pyplot_api.html?highlight=hist#matplotlib.pyplot.hist)

If you take a look at that gallery and search for histogram, you will find this example which fits your needs: http://matplotlib.org/examples/statistics/histogram_demo_histtypes.html

  • The example does give a a histogram, but not the one I was expecting. Above someone posted a link to the same question with the answer to use the bins as data and the data as weights. – user4050567 Oct 15 '14 at 16:27