2012-03-12 59 views
5

如何在任何給定的座標範圍內繪製對角線(從左下角到右上角 右上角), ?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") 

回答

9

當前繪圖區的範圍是par()$usr

lines(par()$usr[1:2], par()$usr[3:4])