user308827
user308827

Reputation: 22021

Changing legend location seaborn factorplot

g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=exercise)

In seaborn, is there a way to plot the legend in the first sub-plot instead of second? This example is from here: https://seaborn.pydata.org/generated/seaborn.factorplot.html?highlight=factor#seaborn.factorplot

Upvotes: 2

Views: 1151

Answers (2)

mwaskom
mwaskom

Reputation: 49022

There is an even easier way:

g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet",
                   data=exercise, legend_out=False)

enter image description here

Upvotes: 1

Nipun Batra
Nipun Batra

Reputation: 11377

The following should work.

g = sns.factorplot(x="time", y="pulse", hue="kind",
              col="diet", data=exercise, legend=False)
g.axes[0][0].legend()

PS:

  1. How to put the legend on first subplot of seaborn.FacetGrid?

Upvotes: 2

Related Questions