从ggplot2中的geom_smooth中删除线条

时间:2013-04-21 18:01:22

标签: r ggplot2

我试图从geom_smooth中删除回归线,只保留置信区间。我尝试了size = 0size = NULLsize = NA,但都没有效果。有没有人知道的简单解决方法?

baseball <- ddply(x, .(id), transform, bat.avg = h/ab)
hank <- subset(baseball, id == 'aaronha01')
ggplot(hank, aes(x = year, y = bat.avg)) +
  geom_line(size = 1.2, color = '#336699') +
  geom_smooth(fill = '#bf3030', size = NA) +
  labs(x = '', y = '')

Hank Aaron's Batting Average

2 个答案:

答案 0 :(得分:13)

您可以在linetype=0内设置geom_smooth()以删除行。

ggplot(mtcars,aes(wt,mpg))+geom_smooth(linetype=0)

enter image description here

答案 1 :(得分:0)

设置size=0也会删除该行。显然size= NA也是如此。

ggplot(mtcars,aes(wt,mpg))+geom_smooth(size=0)