[R] geom_smooth

Berwin A Turlach berw|n@tur|@ch @end|ng |rom gm@||@com
Sat Aug 12 08:08:29 CEST 2023


G'day Thomas,

On Sat, 12 Aug 2023 04:17:42 +0000 (UTC)
Thomas Subia via R-help <r-help using r-project.org> wrote:

> Here is my reproducible code for a graph using geom_smooth

The call "library(tidyverse)" was missing. :)

> I'd like to add a black boundary around the shaded area. I suspect
> this can be done with geom_ribbon but I cannot figure this out. Some
> advice would be welcome.

This works for me:

ggplot(scatter_data,aes(x=x_var,y=y_var,))+
  geom_point()+
  geom_smooth(se=TRUE,fill="blue",color="black",linetype="dashed") +
  geom_ribbon(stat="smooth", aes(ymin=after_stat(ymin), ymax=after_stat(ymax)), fill=NA, color="black")+
  theme_cowplot()

Cheers,
	
	Berwin



More information about the R-help mailing list