R 完整数据的平滑线(刻面)ggplot2

R 完整数据的平滑线(刻面)ggplot2,r,ggplot2,R,Ggplot2,我想向每个方面添加full数据集的平滑线 ggplot(mpg2,aes(displ,hwy)) + geom_point() + facet_wrap(~class) + geom_smooth(se = FALSE) 但是,下面的代码为每个面添加了不同的平滑线(每个面的)平滑线 ggplot(mpg2,aes(displ,hwy)) + geom_point() + facet_wrap(~class) + geom_smooth(se = FALSE) 如何修复此问题?您可以使用不

我想向每个方面添加full数据集的平滑线

ggplot(mpg2,aes(displ,hwy)) + geom_point()  + facet_wrap(~class) + geom_smooth(se = FALSE)
但是,下面的代码为每个面添加了不同的平滑线(每个面的)平滑线

ggplot(mpg2,aes(displ,hwy)) + geom_point()  + facet_wrap(~class) + geom_smooth(se = FALSE)

如何修复此问题?

您可以使用不包含镶嵌面变量的数据集添加
geom_平滑
层。因此,从数据集中删除
class

ggplot(mpg, aes(displ, hwy)) + 
    geom_point()  + 
    facet_wrap(~class) + 
    geom_smooth(data = mpg[,1:10], se = FALSE)

可以使用不包含镶嵌面变量的数据集添加
geom_smooth
层。因此,从数据集中删除
class

ggplot(mpg, aes(displ, hwy)) + 
    geom_point()  + 
    facet_wrap(~class) + 
    geom_smooth(data = mpg[,1:10], se = FALSE)