seaborn put legend outside of plot code example
Example 1: sns legend outside
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="darkgrid")
# Load the long-form example gammas dataset
gammas = sns.load_dataset("gammas")
# Plot the response with standard error
sns.tsplot(data=gammas, time="timepoint", unit="subject",
condition="ROI", value="BOLD signal")
# Put the legend out of the figure
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
Example 2: seaborn set legend outside
plt.legend(bbox_to_anchor=(1, 1), loc='best', borderaxespad=0.) # Try this
# Other locations include [upper right, upper left, lower left,
# lower right, right, center left, center right, lower center,
# upper center, and center]
# A full example is a bit long, see source.