Python 如何获得pandas.plot(kind=';kde';)的输出?

Python 如何获得pandas.plot(kind=';kde';)的输出?,python,pandas,Python,Pandas,当我绘制熊猫系列的密度分布时,我使用 .plot(kind='kde') 是否可以获得此绘图的输出值?如果是,怎么做?我需要打印的值。没有来自.plot(kind='kde')的输出值,它返回一个轴对象 原始值可通过绘图中的matplotlib.lines.Line2D对象的\ux和\uy方法访问 In [266]: ser = pd.Series(np.random.randn(1000)) ax=ser.plot(kind='kde') In [265]: ax.get_childr

当我绘制熊猫系列的密度分布时,我使用

.plot(kind='kde')

是否可以获得此绘图的输出值?如果是,怎么做?我需要打印的值。

没有来自
.plot(kind='kde')
的输出值,它返回一个
对象

原始值可通过绘图中的
matplotlib.lines.Line2D
对象的
\ux
\uy
方法访问

In [266]:

ser = pd.Series(np.random.randn(1000))
ax=ser.plot(kind='kde')

In [265]:

ax.get_children() #it is the 3nd object
Out[265]:
[<matplotlib.axis.XAxis at 0x85ea370>,
 <matplotlib.axis.YAxis at 0x8255750>,
 <matplotlib.lines.Line2D at 0x87a5a10>,
 <matplotlib.text.Text at 0x8796f30>,
 <matplotlib.text.Text at 0x87a5850>,
 <matplotlib.text.Text at 0x87a56d0>,
 <matplotlib.patches.Rectangle at 0x87a56f0>,
 <matplotlib.spines.Spine at 0x85ea5d0>,
 <matplotlib.spines.Spine at 0x85eaed0>,
 <matplotlib.spines.Spine at 0x85eab50>,
 <matplotlib.spines.Spine at 0x85ea3b0>]
In [264]:
#get the values
ax.get_children()[2]._x
ax.get_children()[2]._y
[266]中的

ser=pd系列(np随机随机随机数(1000))
ax=序列图(kind='kde')
在[265]中:
ax.get_children()#它是第三个对象
出[265]:
[,
,
,
,
,
,
,
,
,
,
]
在[264]中:
#获取值
ax.get_children()[2]。\u x
ax.get_children()[2]。_y

您也可以直接调用
scipy.stats.gaussian_kde()函数,这就是源代码中发生的情况:

该功能的文档是否存在:


!正是我想要的
ax.get_children()
刚刚为我更改了游戏。我不知道你能做到。我已经经历了孩子们的变化。你能直呼他们的名字吗?相关的熊猫代码已经转移到