使用pandas绘制图形直方图和正态密度
我想从一个像这样的数据系列中绘制正常的密度图和直方图,但一直没能做到。就像下面这个链接所示: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)
2 个回答
0
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,里面展示了两个直方图和两个密度图的更复杂的情况。
1