I'm making a scatter plot of a metabolic rate according to the time with 2 qualities conditions and I'm using the stat_smooth function with a lm model to have the curves of my scatter plot. I would like to create an area under these curves (with a different color for each quality) but when I try with geom_ribbon, it creates the areas according to the dots, not the curves.
Here is my script :
metabo_temps_quantity = ggplot(data_metabo, aes(x = time, y = metabolic_rate, col=quality)) +
geom_point(aes(color = quality), size = 3)+
geom_ribbon(data=data_metabo,aes(x=time,ymax=metabolic_rate),ymin=0, alpha=0.3) +
theme_classic()+
stat_smooth(method='lm')+
facet_wrap(~quantity)+
theme_minimal()+
theme_grey(base_size = 22)
metabo_temps_quantity
How could I do that ?
Thanks in advance !
