Geom_smooth in ggplot forces part of the plot background to change color

How can I avoid gray shading of the graph area that occurs when building the following data?

df <-data.frame(x = c(0,0.2,0.5), y = c(0.6,0.7,0.9)) p <-ggplot(df, aes(x, y, ymin=0, ymax=1, xmin=0, xmax=1)) p <- p + geom_point(alpha=2/10, shape=21, fill="blue", colour="black", size=5) p 

enter image description here

So good up to this point, but then adding a linear equation using geom_smooth, part of the background will turn gray.

 p <- p + geom_smooth(method="lm", se=FALSE, formula=y~x, colour="black") p 

enter image description here

Any suggestions on how to avoid this? Thanks.

+6
source share
1 answer

Add fill=NA to your geom_smooth call:

 p + geom_smooth(method="lm", se=FALSE, formula=y~x,colour="black",fill=NA) 
+7
source

Source: https://habr.com/ru/post/922671/


All Articles