Closed sorenwacker closed 1 year ago
I am using kind='kde'
:
g = sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species", kind='kde')
g.ax_joint.legend(bbox_to_anchor=(1.5, 1.1))
JointGrid is a bit peculiar because unlike the other Grid objects, the legend is not attached to the figure but directly to the central ax. sns.move_legend(g.figure.axes[0],loc=...)
will do the trick.
This works:
g = sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species", kind='kde')
sns.move_legend(g.ax_joint, "upper left", bbox_to_anchor=(.55, .45), title='Species')
That's right; either approach will work, though I'd recommend the second as both shorter and more explicit.
Hi,
I am trying to move the legend of a jointplot, but none of the methods works. I tired
This works for 0.11.2, but not for 0.12.2:
In seaborn 0.12.2 the legend is moved, but also cleared of any labels.
Also
penguins = sns.load_dataset("penguins")
does not work with 0.12.2. Just ran into this while generating this issue.Note: This is probably because I have to use Python 3.8.16.