Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove line from geom_smooth in ggplot2

Tags:

r

ggplot2

I am trying to remove the regression line from geom_smooth and only keep the confidence interval. I have tried size = 0, size = NULL, and size = NA, but none work. Is there a simple workaround that anyone knows?

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

like image 307
maloneypatr Avatar asked Apr 21 '13 18:04

maloneypatr


1 Answers

You can set linetype=0 inside geom_smooth() to remove line.

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

enter image description here

like image 200
Didzis Elferts Avatar answered Oct 10 '22 11:10

Didzis Elferts