Skip to content
Prev 32326 / 398513 Next

legend() with option adj=1

Jerome Asselin wrote:
Works, e.g., with the following little trick:

  x <- 1:5
  y1 <- 1/x
  y2 <- 2/x
  plot(rep(x,2),c(y1,y2),type="n",xlab="x",ylab="y")
  lines(x,y1)
  lines(x,y2,lty=2)
  temp <- legend(5, 2, legend = c(" ", " "),
    text.width = strwidth("1,000,000"), lty = 1:2, xjust = 1, yjust = 1)
  text(temp$rect$left + temp$rect$w, temp$text$y,
     c("1,000", "1,000,000"), pos=2)

See ?legend for details, in particular the returned value.

Uwe Ligges