从seaborn tutorial我画了一个图:
import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.swarmplot(x=tips["total_bill"])
现在我想获得包含到make in interactive using mpld3的数据的PathCollection的句柄。我查看输出ax
子级,得到以下列表:
[<matplotlib.collections.PathCollection at 0x7828d325f8>,
<matplotlib.spines.Spine at 0x782824a518>,
<matplotlib.spines.Spine at 0x782824ab38>,
<matplotlib.spines.Spine at 0x782824a748>,
<matplotlib.spines.Spine at 0x782824a940>,
<matplotlib.axis.XAxis at 0x782824acf8>,
<matplotlib.axis.YAxis at 0x78282e5518>,
<matplotlib.text.Text at 0x78282fb710>,
<matplotlib.text.Text at 0x78282fb0b8>,
<matplotlib.text.Text at 0x78282fb208>,
<matplotlib.patches.Rectangle at 0x78282fb0f0>]
但是,当我在PathCollection中查找数据时,它是空的
ax.get_children()[0].get_array()
如何找到包含数据点的PathCollection的句柄?你知道吗
包含数据点的
PathCollection
是ax.get_children()[0]
。调用.get_array()
的结果是None
(不是空的),但这不会阻止您对PathCollection
使用mplot3d。此代码适用于我:做了一个Jupiter notebook只是为了好玩。你知道吗
相关问题 更多 >
编程相关推荐