【发布时间】:2021-06-20 00:59:26
【问题描述】:
获取以下数据和图表
df <- data.frame(ID = c(1, 1, 2, 2, 3, 3),
cond = c(2, 2, 2, 2, 2, 2),
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))
ggplot(df, aes(x = Time, y = eye)) +
geom_point(aes(shape=State), size = 3.5) +
scale_shape_manual(values=c(13,15)) +
geom_line(aes(group=ID, color = Time), size = 5) +
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"))
如何让线条变成渐变色?图例显示了渐变颜色方案,但如图所示,线条似乎没有准确地跟随它。
【问题讨论】: