Draw lines between two facets in ggplot2

Sunday, July 6, 2014

How can I draw several lines between two facets?


I attempted this by plotting points at the min value of the top graph but they are not between the two facets. See picture below.


enter image description here


This is my code so far:



t = seq(1:1000); y1 = rexp(1000); y2 = cumsum(y1)
z = rep(NA, length(t)); z[100:200] <- 1

df = data.frame(t=t, values=c(y2,y1), type=rep(c("Bytes","Changes"), each=1000))
points <- data.frame(x=c(10:200,300:350), y=min(y2), type=rep("Bytes",242))
vline.data <- data.frame(type = c("Bytes","Bytes","Changes","Changes"), vl=c(1,5,20,5))

g = ggplot(data=df, aes(x=t, y=values)) +
geom_line(colour=I("black")) +
facet_grid(type ~ ., scales="free") +
scale_y_continuous(trans="log10") +
ylab("Log values") +
theme(axis.text.x = element_text(angle = 90, hjust = 1), panel.margin = unit(0, "lines"))+
geom_point(data=points, aes(x = x, y = y), colour="green")

g






http://ift.tt/1jbRawf