hadley/ggplot2 — Issue #255: vars in aes() which aren't present in secondary data frame cause problems
Author: wch
Created: 2011-11-01 21:47:57+00:00
State: open

d1 <- data.frame(x=1:10, y=rnorm(10), ci=(1:10)/10)

d2 <- data.frame(x=2*(1:5), y=rnorm(5))

ggplot(d1, aes(x=x, y=y)) +
geom_ribbon(fill="grey80") +
geom_line() +
geom_line(data=d2, colour="red")

ggplot(d1, aes(x=x, y=y)) +
geom_ribbon(aes(ymin=y-ci, ymax=y+ci), fill="grey80") +
geom_line() +
geom_line(data=d2, colour="red")