From: Jeffrey B. <jbl...@al...> - 2012-03-01 17:49:35
|
Hi, > I'm currently using the hist plot from matlibplot. Here I have the > following > question: is there an easy way to set the bin content of a > specified bin? > For example, I would like to call set_bin_content(bin_index=1, > value=10000) > once instead of filling in 10000 times the same value. You can do this by separating the histogram calculation from the plotting. import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt # generate data here; for example data = np.random.randn(500) myHist, myBinEdges = np.histogram(data) # edit myHist to your heart's delight wid = myBinEdges[1:] - myBinEdges[:-1] plt.bar(myBinEdges[:-1], myHist, width=wid) plt.show() -Jeff |