[R] Re : How to plot diagonal line at any coordinate range in R

Pascal Oettli kridox at ymail.com
Mon Mar 12 06:33:51 CET 2012


Hi  G.V.

Does it fit to your request?


plot(c(-2,3), c(-1,5), type = "n", xlab="x", ylab="y", asp = 1)
dg <- par("usr")
segments(dg[1],dg[3],dg[2],dg[4], col='red')

Regards,
Pascal

----- Mail original -----
De : Gundala Viswanath <gundalav at gmail.com>
À : r-help at stat.math.ethz.ch
Cc : 
Envoyé le : Lundi 12 mars 2012 14h15
Objet : [R] How to plot diagonal line at any coordinate range in R

Dear expert

How can we plot diagonal across (from bottom-left-hand corner to top
right-hand corner),
at any given coordinate range

For example

> plot(c(-2,3), c(-1,5), type = "n", xlab="x", ylab="y", asp = 1)
or
> plot(c(0,1000), c(0,334), type = "n", xlab="x", ylab="y", asp = 1)

I tried abline with the following but failed:

> abline(0,1,col="red")

- G.V.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list