当kdeplot的输入为2D时,是否可以从其获取数据? 我有以下资料:
import numpy as np
from seaborn import kdeplot
lA = np.randon.normal(1,0.2,1000)
ld = np.randon.normal(1,0.2,1000)
kde = kdeplot(x=lA,y=ld)
如果这只是1D,我可以通过以下方式获得信息:
lA = np.randon.normal(1,0.2,1000)
kde = kdeplot(lA)
line = kde.lines[0]
x, y = line.get_data()
但是作为一个例子,输入是2D(lA, ld)
,它返回一个<AxesSubplot:>
对象,我不知道如何解压缩它的信息,因为kde.lines[0]
然后返回list index out of range
。
我需要计算每个绘制轮廓轴上的最大值和最小值(分别)作为每个变量的离散度
在本例中,可以从LineCollection对象获取图形中绘制的路径
感谢r初学者提供的解决方案,它确实解决了问题。我只是在访问数据[0]以获取“顶点”值时遇到了一些问题,因为它是一个路径对象,我不熟悉这些对象。 但根据您的回答,我认为(针对我的特定问题)使用以下方法可能更简单:
相关问题 更多 >
编程相关推荐