简体   繁体   中英

Seaborn lmplot truncates trendline for some plots

When I run the following code, the regression line for some of the plots is truncated, even though I specified truncate=False.

import seaborn as sns

sns.set()
tips = sns.load_dataset('tips')
sns.lmplot(x='total_bill',y='tip',data=tips,truncate=False,col='day',hue='sex')

https://i.stack.imgur.com/YA0Ca.png

Is there any way to make it so the line extends to the limits in all of the plots?

AFAIK This is ultimately a matplotlib issue (see comment), but it can be worked around:

import seaborn as sns
sns.set()
tips = sns.load_dataset('tips')
g = sns.FacetGrid(data=tips, col="day", hue="sex")
g.set(xlim=(0, 55))
g.map(sns.regplot, "total_bill", "tip", truncate=False)
g.add_legend()

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM