Change standard error color for geom_smooth
Your (understandable) mistake is to think that you should be changing the color rather than the fill. The standard error shadings are made with geom_ribbon
essentially, and they are a 2d area, so the "color" they are "filled" with is determined by fill
, not colour
.
Try:
geom_smooth(aes(...,fill = variable))
where variable is the same one you map to colour elsewhere.
If you have multiple groups you simple define color = Vars
and group = Vars
within ggplot(aes())
, and then additional aes(fill = Vars)
within geom_smooth(aes(fill = Species))
. (Based on answer here)
Dummy example:
# Make confidence intervals the same color as line by group
ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
group = Species,
color = Species)) +
geom_point() +
geom_smooth(aes(fill = Species)) # additional `aes()` referencing to confidence interval as a `fill` not as a `color`