I\'m trying to create a facet_wrap
plot that compares four separate lines to a common fifth line; the goal is to have this fifth line appearing on all four of the o
You could also use geom_abline(...) as follows:
x <- c( 1, 3, 1, 3, 2, 4, 2, 4)
y <- c( 1, 3, 2, 4, 1, 3, 2, 4)
type <- c("A","A","B","B","C","C","D","D")
data <- data.frame(x,y,type)
int <- c(5,5,5,5)
slope <- c(-1,-1,-1,-1)
type <- c("A","B","C","D")
ref <- data.frame(int, slope, type)
ggplot(data, aes(x,y)) + geom_line() + facet_wrap(~type, scales="free") +
geom_abline(data = ref, aes(intercept=int, slope=slope), color="red", size=2)
Which produces this: