Consider the following code:
library(ggplot2) foo <- data.frame(x=1:10,A=1:10,B=10:1) ggplot(melt(foo,id.vars=\"x\"),aes(x,value,color=variable))+geom_lin
The order of your A,B inside data.frame(x=1:10,A=1:10,B=10:1) is causing this layering issue because it is drawing A (1:10) first.
A,B
data.frame(x=1:10,A=1:10,B=10:1)
If you use data.frame(x=1:10,A=10:1,B=1:10) is will put the ascending line on top (since B is drawn last).
data.frame(x=1:10,A=10:1,B=1:10)