如何从matplotlib seaborn plot中删除特定的孩子

时间:2015-03-23 08:52:17

标签: python matplotlib seaborn

我正在使用seaborn jointplot来创建等高线图和各自的分布。 enter image description here

由于 pearsonr 与图中的消息无关,我想将其删除(以避免混淆)。在启动seaborn jointplot命令时,我既不能阻止它被放在那里,我也没有找到一种方法将孩子从阴谋中移除。

ax.get_children()

命令返回以下子项:

[<matplotlib.axis.XAxis at 0x7f03778cdc90>,
 <matplotlib.axis.YAxis at 0x7f03778e5b90>,
 <matplotlib.legend.Legend at 0x7f0377703dd0>,
 <matplotlib.collections.PathCollection at 0x7f037ba60c90>,
 <matplotlib.collections.PathCollection at 0x7f0378325310>,
 <matplotlib.collections.PathCollection at 0x7f0377754a10>,
 <matplotlib.collections.PathCollection at 0x7f0377754f50>,
 <matplotlib.collections.PathCollection at 0x7f037776e4d0>,
 <matplotlib.collections.PathCollection at 0x7f037776ea10>,
 <matplotlib.collections.PathCollection at 0x7f037776ee90>,
 <matplotlib.collections.PathCollection at 0x7f03776f73d0>,
 <matplotlib.quiver.Quiver at 0x7f0377b79dd0>,
 <matplotlib.text.Text at 0x7f037789a6d0>,
 <matplotlib.text.Text at 0x7f037789a710>,
 <matplotlib.text.Text at 0x7f037789a750>,
 <matplotlib.patches.Rectangle at 0x7f037789a790>,
 <matplotlib.spines.Spine at 0x7f03778cdb50>,
 <matplotlib.spines.Spine at 0x7f0377953f50>,
 <matplotlib.spines.Spine at 0x7f03778cd9d0>,
 <matplotlib.spines.Spine at 0x7f03778bb390>]

但是ax.get_children()[12] .remove()以

结束
raise NotImplementedError('cannot remove artist')

似乎seaborn以某种方式阻止了plt.ion()或/和其他重绘内容。 我期待解决方案非常简单(find_object命令+删除的某种组合)。有什么建议?

1 个答案:

答案 0 :(得分:2)

来自docs

  

stat_func :可调用或无

     

用于计算关系统计量并注释绘图的函数。应该将x和y映射到单个值或a   (值,p)元组。 如果您不想注释剧情,请设置为无。

因此,在致电jointplot时,只需将stat_func设为None