R中的柔性对角线图

nev*_*int 5 plot r line diagonal

在任何给定的坐标范围内,我们如何绘制对角线(从左下角到右上角)?

例如

> plot(c(-2,3), c(-1,5), type = "n", xlab="x", ylab="y", asp = 1)
Run Code Online (Sandbox Code Playgroud)

要么

> plot(c(0,1000), c(0,334), type = "n", xlab="x", ylab="y", asp = 1)
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下内容但是失败了:

> abline(0,1,col="red")
Run Code Online (Sandbox Code Playgroud)

Vin*_*ynd 9

当前绘图区域的限制是par()$usr.

lines( par()$usr[1:2], par()$usr[3:4] )
Run Code Online (Sandbox Code Playgroud)