0

I need to create a histogram using matplotlib that decides the height of the bar using the value provided instead of frequencies.

Eg-list=[27,28,13,56,43] contains people opted for a particular subject.

should generate a histogram that has values 27,28,13,56,43 on y axis(or range of values like 0-10,10-20 ....) and on x-axis , the names of the subject.Since,I'm a newbie,I don't know what to do?

pylab.xlabel("Topics")
bins=range(0,100,1)
pylab.ylabel("Number of people interested")
pylab.hist(result,bins)

results in

histogram divided with frequencies

please help

Ammy
  • 13
  • 5
  • If digging into pyplot's help doesn't give you want you want, you probably have to switch to generating the histogram with `numpy.hist` and plotting it manually afterward. That's much more flexible. – Andras Deak -- Слава Україні Dec 20 '16 at 13:43
  • 1
    The linked question (and links from there) *should* provided all the information and examples you need to get started with histograms. Please let me know if it doesn't! – Wayne Werner Dec 20 '16 at 13:49
  • 1
    Pretty sure that duplicate doesn't help here. The OP has the histogram data already, and just wants to plot it, no? OP: you probably want to use `plt.bar` instead of `plt.hist`, since `plt.hist` will only work when you provide it all the data and it works out the frequencies for you. – tmdavison Dec 20 '16 at 14:52
  • The second answer does answer this question and explains why using `plt.hist` for this is not the correct tool. – tacaswell Dec 20 '16 at 21:17
  • Thanks for all the help.I am using matplotlib subplot bar to fullfill my requirement and it works like a charm. – Ammy Dec 21 '16 at 09:47

0 Answers0