Matplotlib's hist
says "Compute and draw the histogram of x". I'd like to make a plot without computing anything first. I have the bin widths (unequal), and the total amount in each bin, and I want to plot a frequency-quantity histogram.
For instance, with the data
cm Frequency
65-75 2
75-80 7
80-90 21
90-105 15
105-110 12
It should make a plot like this:
http://www.gcsemathstutor.com/histograms.php
where the area of the blocks represents the frequency in each class.
Working on the same as David Zwicker:
import numpy as np
import matplotlib.pyplot as plt
freqs = np.array([2, 7, 21, 15, 12])
bins = np.array([65, 75, 80, 90, 105, 110])
widths = bins[1:] - bins[:-1]
heights = freqs.astype(np.float)/widths
plt.fill_between(bins.repeat(2)[1:-1], heights.repeat(2), facecolor='steelblue')
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With