I am using alpha to set transparency for the smoothing line in ggplot but instead I get transparency only in the Error band that surrounds the fitted line.
My code is the following:
z1 <- rnorm(10)
z2 <- z1 ^ 2
error <- rnorm(10, 0.25)
y <- 1 + 0.5 * z1 + error
data1 <- data.table(y, z1, z2)
ggplot(data1) +
geom_point(aes(x = z1, y = y), color = "blue", size = 3) +
geom_point(aes(x = z2, y = y), color = "red", size = 3) +
geom_smooth(method = lm, aes(x = z1, y = y), color = "blue", size = 2, alpha = 0.1) +
geom_smooth(method = lm, aes(x = z2, y = y), color = "red", size = 2, alpha = 0.1)
How can I set explicitly the transparency of the regression line as well?
Your advice will be appreciated.