将文字添加到指定位置的绘图中

时间:2018-10-17 14:59:16

标签: r text legend

我想在下图中的每行中添加标签: enter image description here

a <- 1:2000
b <- a - a[1]

plot(1, type = "n", xlab = "Scale parameter", ylab = "No. of days", xlim = c(0, 90), ylim = c(0, 150))
shape.range <- seq(from = 2, to = 10, by = 1)
scale.range <- seq(from = 10, to = 70, by = 1)

for(sh in seq_along(shape.range)){

sh.ref <- shape.range[sh]

 for(sc in seq_along(scale.range)){

   sc.ref <- scale.range[sc]
   p <-  1 - exp(-(b/sc.ref)^sh.ref)
   p.l <- which.max(p >= 0.97)

   points(sc.ref,   p.l, cex = 0.5, pch = 19)
#  text(80, # how to insert the value of y here such that the label ends up at the end of the each line, labels = paste0(sh.ref))
  }
}

1 个答案:

答案 0 :(得分:0)

不是所有事情都需要ggplots。基本图形有时更容易调整。

只需在代码后添加这些行即可。

text(20,100,"Text left")
text(60,20,"Text right")

enter image description here