Take the following data
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))
and the plot
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, alpha = State), 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"))
which produces
my problem is
this gives the lines different alphas, but I want the lines to have gradient alpha. Specifically, I need the line that goes between 'empty' and 'full' state to start with low alpha and end with high alpha, and the line that goes from 'full' to 'empty' to start with high alpha and end with low alpha. (the line that goes from 'low' to 'low' is okay as it is in the example).
On the x-axis, instead of starting at x = 1 and ending at x = 2, I want the 'empty' to 'full' line to start at 1.25 and then 'fade in' to end at 2, and I want the 'full' to 'empty' line to start at 1.00 and 'fade out' to end at 1.75.
I have been hassling with this problem for a while now, any help is much appreciated.