I have this situation where I am plotting a series of lines, something like the following:
library(foreach)
library(ggplot2)
df.test <- foreach(ix = seq(0,1,by=0.01),.combine=rbind) %do% {
theta = seq(-pi,pi,by=pi/100)
data.frame(IX=ix,theta=theta,value=ix*sin(theta))
}
ggplot(df.test,aes(x=theta,y=value,color=IX,group=IX,order=-IX)) + geom_path() +
theme_bw() + labs(x="Theta",y="Sin(Theta)",color="Index",title="Example Plot") +
theme(legend.position=c(0,1),legend.justification=c(0,1))
Which produces a plot as follows:
If you look closely at the origin, the values of high index value (light blue) are stacked on top of the lines with low index value (dark blue).
How can I reverse this, so that the dark blue lines (low index) are stacked on top of the light blue lines (high index).
The above is analogous to my actual problem, where I am plotting scientific data for various temperatures. The low temperature values are more meaningful than the high temperature values, so I do not want the low temperature lines to be potentially masked by the high temperature lines, in fact the opposite is my preference.