[R] aspect ratio 1 and blank space

Peter Ehlers ehlers at ucalgary.ca
Thu Nov 18 06:39:58 CET 2010


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.



More information about the R-help mailing list