R中的灵活对角线图
问题描述:
如何在任何给定的坐标范围内绘制对角线(从左下角到右上角 右上角), ?R中的灵活对角线图
例如
> plot(c(-2,3), c(-1,5), type = "n", xlab="x", ylab="y", asp = 1)
或
> plot(c(0,1000), c(0,334), type = "n", xlab="x", ylab="y", asp = 1)
我试图abline具有以下,但未能:
> abline(0,1,col="red")
答
当前绘图区的范围是par()$usr
。
lines(par()$usr[1:2], par()$usr[3:4])