Python 能否从Pandas绘图调用中导出直方图y值?

Python 能否从Pandas绘图调用中导出直方图y值?,python,pandas,matplotlib,Python,Pandas,Matplotlib,假设我试图将年龄绘制为带有密度计数的直方图: ax = inputs['Age'].plot(kind='hist', bins=10, range = (20,100), grid=True, density=True) 是否有办法从返回的每个箱子的密度计算y值 或者我必须为每个箱子分别计算它们吗 而pandas.Series.plot不返回存储箱,matplotlib.pyplot.hist返回存储箱。因此,如果您想获得完全相同的地块和垃圾箱,可以使用: bins, values, _ =

假设我试图将年龄绘制为带有密度计数的直方图:

ax = inputs['Age'].plot(kind='hist', bins=10, range = (20,100), grid=True, density=True)
是否有办法从返回的每个箱子的密度计算y值


或者我必须为每个箱子分别计算它们吗

pandas.Series.plot
不返回存储箱,
matplotlib.pyplot.hist
返回存储箱。因此,如果您想获得完全相同的地块和垃圾箱,可以使用:

bins, values, _ = ax.hist(inputs['Age'], bins=10, range = (20,100), density = True)
ax.grid() # there is no grid=True option in matplotlib.pyplot.hist

您可以使用matplotlib.pyplot.hist,它返回箱子和值hanks Arco Blast!虽然奇怪的是,它不能从Pandas软件包本身返回,但这确实有效。
numpy.histogram
也是一个选项,尽管我同意Arco Bast的建议,即使用
matplotlib.pyplot.hist
而不是
Pandas.DataFrame.plot
很高兴听到它有效。。。我已经回答了。