Manual Histogram plot in python

Viewed 4188

I'm using matplotlib to make a histogram.

Basically, I'm wondering if there is any way to manually set the bins as well as the their values and still get the result as if the graph is made my matplotlin histogram. Below are my bins and their corresponding value.

0-7     0.9375
7-13    0.9490740741
13-18   0.8285714286 
18-28   0.880952381
28-37   0.92164903
37-48   0.9345357019
48-112  0.9400368773

This is the bar code i have implemented

import matplotlib.pyplot as plt
plt.bar(maxlist, mean)
plt.show()

maxlist = [7.0, 13.0, 18.0, 28.0, 37.0, 48.0, 112.0]
mean = [0.9375, 0.94907407407777766, 0.82857142858571442, 0.88095238094999995, 0.92164902996666676, 0.93453570191250002, 0.94003687729000018]

This is what the bar plot of the above code looks like. histwithoutwidth

I also tried playing with width parameter but the bar seems to overlap in that case, which doesn't happen in histogram.

import matplotlib.pyplot as plt
plt.bar(maxlist, mean,width = 6)
plt.show()

enter image description here

What i want is the bar plot to look like histogram as shown below, without any overlaps. Anyone with any ideas how to do this in python /ipython notebook. enter image description here

1 Answers
Related