take the following data
df <- data.frame(ID = c(1, 1, 2, 2, 3, 3),
cond = c(2, 2, 2, 2, 1, 1),
Time = c(1,2,1,2,1,2),
State = c(0, 0, 0, 1, 1, 0),
eyes = c(2, -3, -2, 1, 0, -2),
combination = c("1", "1","2", "2", "3", "3"))
df$cond <- factor(df$cond,levels = c("1", "2"))
ggplot(df, aes(x = Time, y = eyes)) +
ggforce::geom_link2(aes(group=ID, color = cond, alpha = State), size = 5, n = 500, lineend = "round") +
scale_color_manual(values=c("#CC6666", "#9999CC")) +
scale_alpha_continuous(range = c(0.01, 0.9)) +
scale_shape_manual(values=c(13,15)) +
theme(legend.title=element_blank(),
axis.title.x=element_text(size = 12),
axis.title.y=element_text(size = 12),
plot.title = element_text(hjust = 0.5, size = 15),
axis.text.x= element_text(color = "black"),
axis.text.y= element_text(color = "black"),
axis.line = element_line(colour = "black"),
plot.background = element_rect(fill = "white"),
panel.background = element_rect(fill = "white"))
This produces the following picture:
I am trying to make line 2 and 3 appear / disappear across the x-axis by a continuous change in alpha. Although the lines are drawn between two values (0, 1), the alpha does not seem to change evenly across the line (start as 0.01 alpha at value 0, and 0.9 alpha at value 1) . Instead, the lines almost immediately grows to the full 0.9 alpha - why is this and how do I fix it?