SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: EnderWiggin <jan...@go...> - 2012年02月29日 09:09:48
Hi all,
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.
Thank you very much.
Best regards
-- 
View this message in context: http://old.nabble.com/Setting-the-bin-content-of-a-histogram-tp33412466p33412466.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
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
From: EnderWiggin <jan...@go...> - 2012年03月02日 13:49:56
Hi Jeff,
thank you for your answer. It was very helpful to me.
Have a nice weekend!
-Jan
-- 
View this message in context: http://old.nabble.com/Setting-the-bin-content-of-a-histogram-tp33412466p33428602.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /