Joe
Joe

Reputation: 397

How to hide the undrlying data in a ggplot scatterplot

I am trying to make a scatter plot in ggplot and would like to loose the points and show only the smooth line and the confidence interval. I checked geom_point() function and there is no option for turning it off such that the points/underlying data is hidden. Any suggestions? much appreciated.

Joseph

Upvotes: 0

Views: 3008

Answers (1)

Didzis Elferts
Didzis Elferts

Reputation: 98449

To plot smooth line with confidence interval around the line you should use geom_smooth(). This will smoothed line using loess if there are less than 1000 observations and gam if more. But you can change smoothing method with argument method=.

ggplot(mtcars,aes(wt,mpg))+geom_smooth()

enter image description here

Upvotes: 1

Related Questions