Building on @user308827's answer: you can use legend=False
in factorplot and specify the legend through matplotlib:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot("class", "survived", "sex",
data=titanic, kind="bar",
size=6, palette="muted",
legend=False)
g.despine(left=True)
plt.legend(loc='upper left')
g.set_ylabels("survival probability")
plt
acts on the current axes. To get axes from a FacetGrid
use fig.
g.fig.get_axes()[0].legend(loc='lower left')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…