text与指定的参数一起使用。或者使用legend如图所示的函数。
abline是经典图形,因此假设您想要使用该绘图系统,但如果您想要 ggplot2,请参阅在 ggplot2 中添加水平线来绘图和图例,并进行明显的修改以将水平线更改为垂直线。
x <- y <- 1:10; v <- 5 # input
plot(x, y)
abline(v = v, col = "red")
text("Vertical Line", x = v, y = max(y), srt = -90, pos = 4) # near top
text("Vertical Line", x = v, y = min(y), srt = 90, adj = c(0, -0.5)) # near bottom
legend("topleft", legend = "Vertical Line", pch = "|", col = "red")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3567 次 |
| 最近记录: |