Is it possible to add multiple smoothed order lines in the same lmplot?

154 Views Asked by At

I would like to show multiple smoothed order lines in the same graph using lmplot from seaborn. For example I would like to show an smoothed order line of 1 and 5 colored in the same graph. Here are two example graphs I would like to have combined in one:

import seaborn as sns
tips = sns.load_dataset("tips")
sns.lmplot(x="total_bill", y="tip", order = 1, ci = None, truncate = True, data=tips)

Output order = 1:

enter image description here

sns.lmplot(x="total_bill", y="tip", order = 5, ci = None, truncate = True, data=tips)

Output order = 5:

enter image description here

So I would like to show these two lines in one graph with a legend. It is not supported to have a list as input for the order argument. Does anyone know if it is possible to show multiple smoothed order lines in the same graph using lmplot from seaborn?

1

There are 1 best solutions below

0
Josh Friedlander On BEST ANSWER

You can give use regplot (which lmplot is based on), and initialise an Axes object first, in which case it will just get the current Axes and plot on it. You can probably do this with lmplot too, just too lazy to figure it out...

_, ax = plt.subplots()
sns.regplot(label='order=1', order=1, x="total_bill", y="tip"...etc)
sns.regplot(label='order=5', order=5, x="total_bill", y="tip"...etc)
plt.legend()

enter image description here