I want to change the line style in seaborn implot. I know that we can do the following for changing line style for one regression line.
sns.lmplot(x='xx' , data=dataset, y='yy',line_kws={'ls':'--'})
But what about using hue in implot, when we have three regression line for example:
sns.lmplot(x='xx' , data=dataset, y='yy',hue='class', markers=["o", "x", "D"])
How can we do that? How can we change the line style of each regression line?
Don't think you can :( Here's a workaround that looks similar to lmplot but uses regplot in order to control the individual linestyles:
import seaborn as sns; sns.set(color_codes=True)
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
_, ax = plt.subplots(figsize=(6, 6))
for d, m, ls in zip(tips["day"].unique(), ["o", "x", ".", "D"], ["--", ":", "-.", "-"]):
sns.regplot(x="total_bill", y="tip", data=tips.loc[tips.day == d], marker=m, line_kws={"ls":ls}, ax=ax, label=d)
plt.legend()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With