From maechler at stat.math.ethz.ch  Wed Apr 22 19:29:05 2009
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed, 22 Apr 2009 19:29:05 +0200
Subject: [Rd] reversing xlim, ylim in smoothScatter
In-Reply-To: <920402.63507.qm@web8401.mail.in.yahoo.com>
References: <920402.63507.qm@web8401.mail.in.yahoo.com>
Message-ID: <18927.21473.191825.2987@lynne.math.ethz.ch>

>>>>> "SG" == Shashikiran Ganesh <shashikiran_ganesh at yahoo.co.in>
>>>>>     on Wed, 22 Apr 2009 17:16:09 +0530 (IST) writes:

    SG> Hello,
    SG> I have found that in smoothScatter it is not possible to reverse the axes plotted (R version 2.9.0) .?? It appears that this arises from the hard coding of xlim and ylim in smoothscatter.R in the lines :

    SG> x <- x[ xlim[1] <= x[,1] & x[,1] <=xlim[2], ]?? (line? number 25)

    SG> and 

    SG> x <- x[ ylim[1] <= x[,2] & x[,2] <= ylim[2], ]? (line number 31)

    SG> This results in a x being NA if ylim[1] > ylim[2] which results in an error on executing
    SG> ?map <- grDevices:::.smoothScatterCalcDensity(x, nbin, bandwidth)

    SG> To counter this problem, I replaced the above two lines by :
    SG> x <-x [min(xlim) <= x[,1] & x[,1] <= max(xlim), ]

    SG> and 
    SG> x <- x[min(ylim) <= x[,2] & x[,2] <= max(ylim), ]

    SG> and now smoothscatter reverses axes properly if xlim and/or ylim are provided with reversed ranges.?? 

    SG> I am wondering if this would break something somewhere else or if there is a better way to reverse the axes. ? ? (I am a newbie in R programming although I have been using R for some astronomical plots and computations etc...) 

No, I don't think your proposed change could create problems,
but to the contrary, I'd declare it as a simple bug fix,
so it will be part of the next versions of R,
thank you very much!

Martin Maechler, ETH Zurich

    SG> Thanks in advance for your comments!? 
    SG> Shashi
    SG> --
    SG> Shashikiran Ganesh 

    SG> http://www.prl.res.in/~shashi 

    SG> http://cosmicdiary.org/blogs/shashikiran_ganesh/
    SG> Registered linux user number: 39542 (http://counter.li.org)



[Rd] reversing xlim, ylim in smoothScatter
Martin Maechler