This isn't quite a full solution:
It's fairly easy to add a white strip by adding another geom_step command:
events<-rep(c(0,1,2,3,4),4)
individual<-(as.factor(rep(c("A1","A2","B1","B2"),each=5)))
step<-c(1,2,3,4,5,3,4,5,6,7,5,6,7,8,9,7,8,9,10,11)
filled <- rep(c(FALSE,TRUE),each=5)
data_frame<-data.frame(events,individual,step,filled)
ggplot(data_frame, aes(x=events, group=individual, colour=individual, y=step)) +
geom_step(size=1.8) +
scale_colour_manual(values=c("green2","green2", "orange", "orange"), name="Individual") +
geom_step(data=df[df$filled,], size=1.1, colour="white")
Unfortunately I'm not sure how to make the legend consistent with this.
An easier alternative would be to make some lines lighter. You can define a lighten_colour
function:
lighten_colour <- function(colour, lightness=0.5) {
# lightness should be between 0 and 1
white <- col2rgb("white") / 255
colour <- col2rgb(colour) / 255
rgb(t(white*lightness + colour*(1-lightness)))
}
... and use this for the plot colours.
ggplot(data_frame, aes(x=events, group=individual, colour=individual, y=step)) +
geom_step(size=1.8) +
scale_colour_manual(values=c(lighten_colour("green2"),
"green2",
lighten_colour("orange"),
"orange"),
name="Individual")