为什么 geom_smooth 没有显示在我的图表中?
Why is geom_smooth not showing in my graph?
你知道为什么这段代码没有在图上返回线性回归线吗?
ggplot(data = df3, mapping = aes(x = work_growth, y = gdp_growth, col = RegionCode))+
geom_point()+
labs (x= "Growth rate of the working-age population",y = "Growth rate of GDP per capita") +
geom_smooth(method="lm")+
theme_classic() + theme(legend.position = "none")
这是我得到的情节:
这是我正在使用的数据框以供参考:https://drive.google.com/file/d/19XvX_gxlPAmhct9jXfUSd5GPcEQFM4eD/view?usp=sharing
非常感谢任何帮助!
如果您先绘制“平滑”图,则可以稍后使用 regionCode
作为颜色参数通过 aes()
调用绘制这些点
ggplot(data = dat, mapping = aes(x = work_growth, y = gdp_growth))+
labs (x= "Growth rate of the working-age population",y = "Growth rate of GDP per capita") +
geom_smooth(method="lm")+
geom_point(aes(col=RegionCode))+
theme_classic() + theme(legend.position = "none")
你知道为什么这段代码没有在图上返回线性回归线吗?
ggplot(data = df3, mapping = aes(x = work_growth, y = gdp_growth, col = RegionCode))+
geom_point()+
labs (x= "Growth rate of the working-age population",y = "Growth rate of GDP per capita") +
geom_smooth(method="lm")+
theme_classic() + theme(legend.position = "none")
这是我得到的情节:
这是我正在使用的数据框以供参考:https://drive.google.com/file/d/19XvX_gxlPAmhct9jXfUSd5GPcEQFM4eD/view?usp=sharing
非常感谢任何帮助!
如果您先绘制“平滑”图,则可以稍后使用 regionCode
作为颜色参数通过 aes()
调用绘制这些点
ggplot(data = dat, mapping = aes(x = work_growth, y = gdp_growth))+
labs (x= "Growth rate of the working-age population",y = "Growth rate of GDP per capita") +
geom_smooth(method="lm")+
geom_point(aes(col=RegionCode))+
theme_classic() + theme(legend.position = "none")