Hi, I need to produce an ordinary scatter plot and it is vital that the aspect ratio equals 1. I set the axis as: plot(x, y, type="n", asp=1, ,ylim=c(-80,70),xlim=c(0,100)). The problem is that I get some 'additional' blank plot area (basically, the lower bound of xlim becomes quite negative). The xlim is not the range of the x-data, but I need the 0 there for further plotting. Any way to specify that even with asp=1, xlim=c(0,100)? Thanks,
On Windows R 2.12.0, the following seemed to work for me: par(pty="s") ## before plotting plot(1:10,xlim=c(0,20),ylim=c(0,30)) I do not find that setting the asp parameter does anything useful; indeed, the Help documentation seems to be backwards (asp=x/y not y/x). I probably misunderstood and/or misused it, though -- asp seems to interact with the xlim and ylim settings in inscrutable ways ... on Windows, anyway. HTH. Cheers, Bert On Wed, Nov 17, 2010 at 9:26 AM, Silvia Cecere <scecere at yahoo.com> wrote:> > Hi, > I need to produce an ordinary scatter plot and it is vital that the aspect ratio equals 1. > > I set the axis as: > > plot(x, y, type="n", asp=1, ,ylim=c(-80,70),xlim=c(0,100)). > > The problem is that I get some 'additional' blank plot area (basically, the lower bound of xlim becomes quite negative). > > The xlim is not the range of the x-data, ?but I need the 0 there for further plotting. > > > Any way to specify that even with asp=1, ?xlim=c(0,100)? > > Thanks, > > ______________________________________________ > 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. >-- Bert Gunter Genentech Nonclinical Biostatistics
On 2010-11-17 09:26, Silvia Cecere wrote:> > Hi, > I need to produce an ordinary scatter plot and it is vital that the aspect ratio equals 1. > > I set the axis as: > > plot(x, y, type="n", asp=1, ,ylim=c(-80,70),xlim=c(0,100)). > > The problem is that I get some 'additional' blank plot area (basically, the lower bound of xlim becomes quite negative). > > The xlim is not the range of the x-data, but I need the 0 there for further plotting. > > > Any way to specify that even with asp=1, xlim=c(0,100)?It's not clear (to me, at least) what exactly you want to achieve. An aspect ratio of 1 means that you want the x-scale and the y-scale to be equal. The default plot window has dimensions height = width = 7 in, leading to a plot that's roughly square and onto which you want to place an x-scale of extent 100 units and a y-scale of extent 150 units. It's clear that equal units on both axes are going to lead to some 'extension' of the xlims. If you want to avoid that, you'll have to specify different height/width values, something like: x11(height = 7, width = 7 * (100 - 0)/(70 + 80)) and then place your plot call. You might also want to set the xaxs and/or yaxs parameters. - Peter Ehlers> > Thanks, > > ______________________________________________ > 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.
Look at the squishplot function in the TeachingDemos package, it may do what you want, or if not quite then you could perhaps tweak the code to include the values you want and create the correct aspect ratio. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Silvia Cecere > Sent: Wednesday, November 17, 2010 10:26 AM > To: r-help at r-project.org > Subject: [R] aspect ratio 1 and blank space > > > Hi, > I need to produce an ordinary scatter plot and it is vital that the > aspect ratio equals 1. > > I set the axis as: > > plot(x, y, type="n", asp=1, ,ylim=c(-80,70),xlim=c(0,100)). > > The problem is that I get some 'additional' blank plot area (basically, > the lower bound of xlim becomes quite negative). > > The xlim is not the range of the x-data, but I need the 0 there for > further plotting. > > > Any way to specify that even with asp=1, xlim=c(0,100)? > > Thanks, > > ______________________________________________ > 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.