I have a numpy array “data” that just contains a set of integer counts. Given another array “bins”, I just want to make a frequency plot/CDF of the fraction of total entries in “data” that have at least bins[0]-many counts, at least bins[1]-many counts, etc. and make it into a bar plot, in matplotlib. For example, if:
data = [1, 4, 5, 10]
bins = [0, 5, 6, 7]
then the result should be a bar graph that has 0, 5, 6, 7 on the x-axis and then the fraction of data that has values >= 0, then values >= 5, etc. How can I make this kind of “discrete” CDF bar plot with specified bins in matplotlib? Thanks.
If you’re using matplotlib I assume you are also using numpy, so you can just go through
binsand work out the fraction ofdatasuch thatdata>bin, for alldataindatasand for allbininbins.To that effect this could work:
Now just plot
binsagainstfracs, e.g.