According to the information from @naitsirhc, I wanted to find the official API documentation. Here are my finding and some sample code.
matplotlib.Axes
object by seaborn.scatterplot()
.ax.get_legend()
will return a matplotlib.legned.Legend
instance..remove()
function to remove the legend from your plot.ax = sns.scatterplot(......)
_lg = ax.get_legend()
_lg.remove()
If you check the matplotlib.legned.Legend
API document, you won't see the .remove()
function.
The reason is that the matplotlib.legned.Legend
inherited the matplotlib.artist.Artist
. Therefore, when you call ax.get_legend().remove()
that basically call matplotlib.artist.Artist.remove()
.
In the end, you could even simplify the code into two lines.
ax = sns.scatterplot(......)
ax.get_legend().remove()