Reputation: 22031
g = sns.lmplot(x='x', y='y', df, fit_reg=False, hue='z', lowess=True, scatter_kws={'alpha': 0.5}, legend=True)
plt.legend(bbox_to_anchor=(1.01, 0.5), ncol=2)
In the code above, if I set legend=True
, I get both the default single column seaborn legend and the matplotlib legend. If I set `legend=False', then I get neither. How do I draw only the matplotlib 2 column legend?
Upvotes: 0
Views: 1352
Reputation: 21284
Access the legend
property via g.ax
:
# example data
N = 100
data = {"x":np.random.random(N),
"y":np.random.random(N),
"z":np.random.choice([0,1], size=N)}
df = pd.DataFrame(data)
g = sns.lmplot(x='x', y='y', data=df, fit_reg=False, hue='z',
lowess=True, scatter_kws={'alpha': 0.5}, legend=False)
g.ax.legend(bbox_to_anchor=(1.01, 0.5), ncol=2)
Upvotes: 3