【发布时间】:2015-11-06 21:57:43
【问题描述】:
这是我的代码:
ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(cyl)))+
geom_point(stat = "identity")+
theme_bw()+
geom_smooth()
我得到的不是连续平滑的中位数,而是整个数据的中位数看起来断裂且不准确。我认为这是由于“因子(cyl)”功能。
这是我的代码给出的链接:
【问题讨论】:
-
由于你的数据是按
factor(cyl)分组的,所有后续geom都使用这个分组,甚至geom_smoothed。也许你想要这样的东西:ggplot(mtcars, aes(x = wt, y = mpg))+ geom_point(stat = "identity",aes(colour = factor(cyl)))+ theme_bw()+ geom_smooth();颜色只会应用于点,而不是线