0

Within one Figure, I have used the first default linetypes (lty) except the blank one ("0"), and from ggplot2 for the seventh lt="F2" with the lines-function

lines( ..., lty=5, lwd=2) 
lines( ..., lty=6, lwd=2) 
lines( ..., lt="F2", lwd=2)

--> which works fine when displaying the different lines within one Figure.

However, I also want to denote them together in one legend with (I also tried several similar approaches):

legend(x=c( ..., ...), 
       y=c( ..., ...), 
       lty=1:6, lt="F2" < here I want to have linetype "F2" listed at the seventh position, right after lty=6>, 
        lwd=2
    legend=c(expression(paste("some text 1")),
             ...
             expression(paste("some text for 6")),
             expression(paste("some text for 7"))))

I altered the example to a minimal reproducible example in R:

# In the legend, I would like to replace the "3" in lty=c(1, 2, 3) by lt="F2"
x <- seq(-3.5,3.5,0.01)
y1 <- x^2
y2 <- x^2+1
y3 <- x^2+2
plot(x, y1, type="l", lwd=2,
     xlab="x label",
     ylab="y label")
lines(x, y2, lty=2, lwd=2)
lines(x, y3, lt="F2", lwd=2)  # different linetype "F2", works fine when displaying
legend(x=c(2, 3.5), 
       y=c(0, 3.8),
       lty=c(1, 2, 3), lwd=2,  # instead of lty="3" I would like to use "F2" in the legend
       legend=c(expression(paste("y1")),
                expression(paste("y2")),
                expression(paste("y3"))))

Do you have any ideas to also list the seventh linetype of ggplot2 after the ones of the R default linetypes?

Thanks in advance!

Kle
  • 1
  • 1
  • Please read [How to make a great reproducible example in R?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – M-- Jul 17 '17 at 13:46
  • @Masoud Thx! Now, I included one. – Kle Jul 17 '17 at 14:29

0 Answers0