data = data.frame("ID1" = c(1,2,3,1,2,3),
"ID2"=c(1,1,1,2,2,2),
"D" = sample(5:25,6,r=T))
data$DL = data$D-.02*data$D
data$DU = data$D+.02*data$D
data$XVAL = c(1:6)
library(ggplot2)
ggplot(data) +
geom_pointrange(aes(ymin=DL,ymax=DU),y=D,x=XVAL,
colour=as.factor(data$ID1),shape=as.factor(data$ID1),linetype=as.factor(data$ID2))
I wish to generate what is simple: a geom_pointrange figure where colour defined by ID1 and linetype defined by ID2.
I especially am looking to create such a legend as this: enter image description here