cattt84
cattt84

Reputation: 951

How to delete specific child from matplotlib seaborn plot

I am using seaborn jointplot to create a contour plot and respective distributions. enter image description here

As the pearsonr is not relevant for the message of the figure and I wanted to remove it (to avoid confusion). I was neither able to block it being put there when launching the seaborn jointplot command, neither did I find a way so far to remove the child from the plot.

ax.get_children()

command returns the following 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>]

But ax.get_children()[12].remove() finishes with

raise NotImplementedError('cannot remove artist')

It also seems that seaborn somehow blocks plt.ion() or/and other redraw stuff. I am expecting the solution to be quite simple (some combination of find_object command + delete). Any advice?

Upvotes: 0

Views: 1189

Answers (1)

Andrey Sobolev
Andrey Sobolev

Reputation: 12713

From the docs:

stat_func : callable or None

Function used to calculate a statistic about the relationship and annotate the plot. Should map x and y either to a single value or to a (value, p) tuple. Set to None if you don’t want to annotate the plot.

So when calling jointplot, just set stat_func to None.

Upvotes: 2

Related Questions