How to remove the legend in the
I have tried to use the following methods that are known to work on the other seaborn plots, but failed on the jointplot:
plt.legend([],[], frameon=False)
g._legend.remove()
CodePudding user response:
- To remove the legend, the correct part of the
- Moving the
JointGrid
legend can be done withsns.move_legend
, as shown in this
With
sns.jointplot
g.ax_joint.legend_.remove()
can be used, but removing the legend is more easily accomplished by passinglegend=False
to the plot:sns.jointplot(..., legend=False)
.g.ax_joint.
is still required to move the legend.
penguins = sns.load_dataset("penguins") g = sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species") # remove the legend g.ax_joint.legend_.remove() # or # move the legend # sns.move_legend(g.ax_joint, "lower right", title='Species', frameon=False)
- Moving the