取以下数据
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("Empty", "Empty", "Empty", "Full", "Full", "Empty"),
eye = 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 = eye)) +
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_discrete(range = c(0.02, 0.7)) +
geom_point(aes(shape=State), size = 3.5) +
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"))
问题是对于第 2 行和第 3 行,alpha 达到 1 太快(几乎没有部分行是透明的)。我正在寻找一种方法来更改 alpha 如何跨行变化,以便对于第 2 行和第 3 行,更多的行保持在“低 alpha” - 最好,该行应该只在 1.5 点开始变化(x 轴)。
我在这里不知所措,非常感谢任何帮助。