Gundala Viswanath
2012-Mar-12 05:15 UTC
[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.
Jeff Newmiller
2012-Mar-12 05:23 UTC
[R] How to plot diagonal line at any coordinate range in R
Your requirement that the line go from bottom-left to top-right regardless of the coordinates is inconsistent with a slope of 1. Are you sure that is your requirement? --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Gundala Viswanath <gundalav at gmail.com> wrote:>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.
Pascal Oettli
2012-Mar-12 05:33 UTC
[R] Re : How to plot diagonal line at any coordinate range in R
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.
Jeff Newmiller
2012-Mar-12 06:21 UTC
[R] How to plot diagonal line at any coordinate range in R
I remain skeptical of the value of what you are doing, then. Anyway, don't use a slope of one in your abline function call. The easiest way to be sure what your plot ranges are is to define them yourself, and then defining the slope and intercept needed for your abline call is straightforward algebra. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Gundala Viswanath <gundalav at gmail.com> wrote:>> Your requirement that the line go from bottom-left to top-right >regardless of the coordinates is inconsistent with a slope of 1. Are >you sure that is your requirement? > >Yes > >- G.V.