agenis - 11 months ago 28

R Question

I'm refering to this SO question from 2 years ago, with ggplot : Adjust Transparency (alpha) of stat_smooth lines, not just transparency of Confidence Interval

The first method suggested allows to set the alpha transparency of the confidence interval alone:

`ggplot(head(airquality, 60), aes(x=Day, y=Temp, color=factor(Month))) +`

geom_point() + stat_smooth(method = "lm", se=TRUE, alpha=1.0)

The second method allows to set the alpha transparency for the line itself, but you

`se=TRUE`

`ggplot(head(airquality, 60), aes(x=Day, y=Temp, color=factor(Month))) +`

geom_point() + geom_line(stat='smooth', method = "lm", se=TRUE, alpha=0.3)

Answer Source

This calculates the model twice. But normally that shouldn't be a performance issue.

```
ggplot(head(airquality, 60), aes(x=Day, y=Temp, color=factor(Month))) +
geom_point() +
geom_ribbon(stat='smooth', method = "lm", se=TRUE, alpha=0.1,
aes(color = NULL, group = factor(Month))) +
geom_line(stat='smooth', method = "lm", alpha=0.3)
```