Dear friends - another simple question: the assignment of linetype seems to be corrupted in the code below- I would want the solid line to be the lowest  and also want the legend to be correct. I guess R orders the legend names alphabetically and could handle  that but
cannot unnderstand how the lines apparently are switched.

library(ggplot2)

BB <- cbind(c(1,2,3),c(2,4,6),c(3,6,9))
x <- c(2,3,4)
LT <- c("solid","dashed","dotted")

GG <- ggplot()
for (i in 1:3) {
  dd <- data.frame(x,BB=BB[i,],LT=LT[i])
  GG <- GG + geom_line(data=dd,aes(x=x,y=BB,linetype=LT),size=1)

}
GG+scale_y_continuous(breaks=seq(1,10))

I'm on Windows, R 4.0.5

All best wishes

Troels

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to