python - Move seaborn plot legend to a different position? -
i'm using factorplot(kind="bar")
seaborn.
the plot fine except legend misplaced: right, text goes out of plot's shaded area.
how make seaborn place legend somewhere else, such in top-left instead of middle-right?
building on @user308827's answer: can use legend=false
in factorplot , specify legend through matplotlib:
import seaborn sns import matplotlib.pyplot 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")
Comments
Post a Comment