簡體   English   中英

熊貓的圖直方圖和正常密度

[英]Graph histogram and normal density with pandas

我想要像這樣通過serie df繪制法線密度和直方圖密度的圖形,但是沒有實現。 像下面的鏈接http://hypertextbook.com/facts/2007/resistors/histogram.gif

如何使用DataFrame對象做到這一點?

>>> fd
Scenario
s0000      -2.378963
...
s0999       1.368384
Name: values, Length: 1000, dtype: float64
>>> fd.hist(bins=100)

我認為您可以先像fd.hist()一樣繪制直方圖

然后擬合正常密度並用matplotlob對其進行繪制,請參考:

用python擬合直方圖

fig = plt.figure()
ax = fig.add_subplot(111)
fd.hist(ax=ax, bins=100)
ax1 = ax.twinx()
fd.plot(kind="kde", ax=ax1, legend=False )

改編自https://stackoverflow.com/a/26913361/841830 ,其中顯示了兩個直方圖和兩個密度圖的更復雜情況。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM