Remove the trend line caused by geom_smooth in R

I am trying to remove the trend line which is created while using geom_smooth. The expectation is to just get the confidence interval without the trend line.

I am not sure how to go about with it, can someone help me out?

The data frame I am working with is:

structure(list(Date = structure(c(19389, 19417, 19448, 19478, 
19509, 19539, 19570, 19601, 19631, 19662, 19692, 19723, 19754, 
19783, 19814, 19844, 19875, 19905), class = "Date"), Qty = c(34810, 
34963.3333333333, 35513.3333333333, 36946.6666666667, 38803.3333333333, 
38618.3333333333, 40798.3333333333, 42645, 44686.6666666667, 
46246.6666666667, 43283.3333333333, 40358.3333333333, 39831.6666666667, 
40233.3333333333, 40680, 41103.3333333333, 41446.6666666667, 
41683.3333333333)), row.names = 2:19, class = "data.frame")

The code I wrote for this is given below:

Subset <- read_excel("C:/X/X/X/File.xlsx")

ggplot(Subset,aes(x=Date,y=`Qty`))+
  geom_point(color="purple",size=4,pch=20) +
  geom_line(linetype="dashed") +
  geom_smooth()

The plot that arises due to this is given below:

enter image description here

Need to remove the blue trend line which I have marked for better understanding.

>Solution :

This can be acheived by setting the smoother colour to NA, i.e.:

ggplot(Subset,aes(x=Date,y=`Qty`))+
  geom_point(color="purple",size=4,pch=20) +
  geom_line(linetype="dashed") +
  geom_smooth(colour=NA)

Output plot

Leave a Reply