'How can I put individual legend on each of my graph by using lmplot in python?
How can I individually put those linear regression functions on each of my plots? Currently, it only shows on the last graph, but I also need it displays on the other three's too. my current progress
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
anscombe_df = sns.load_dataset("anscombe")
slope, intercept, r_value, p_value, std_err = stats.linregress(anscombe_df['x'],anscombe_df['y'])
d=sns.lmplot(data=anscombe_df, x="x", y="y",hue='dataset', col='dataset',ci=None, sharex=True, sharey=True,
line_kws={'label':"y={0:.1f}x+{1:.1f}".format(slope,intercept)})
d.set(xlim=(0, 20))
plt.legend()
plt.show()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
