AW: Re: [R] R-Graphics: Scaling axis

Till Baumgaertel till.baumgaertel at epost.de
Wed Mar 12 10:38:45 CET 2003


Thank you!
Adding asp=1 to the plot-command does exactly what I want!

bye,
till

>-- Original Nachricht --
>From: ripley at stats.ox.ac.uk
>Date: Wed, 12 Mar 2003 07:15:30 +0000 (GMT)
>To: Thomas W Blackwell <tblackw at umich.edu>
>cc: Till Baumgaertel <till.baumgaertel at epost.de>,
>        r-help <r-help at stat.math.ethz.ch>
>Subject: Re: [R] R-Graphics: Scaling axis
>
>
>Excuse me, but that is not `how you do it'. R has two automated ways. One
>is the parameter `asp': see ?plot.window, and the other is the function

>eqscplot() in package MASS.  Neither need manual intervention (unless your
>
>output device cannot plot square pixels as square).
>
>We need to be a bit careful about the length of axes: if x ranges from
1
>to 10, the x axis does not (unless you set xaxs="i").  That's why setting
>the plot region (e.g. using par(pty="s") or via the margins) often does
>not do what one wants: the plot region may be square but the scales 
>unequal.
>
>On Tue, 11 Mar 2003, Thomas W Blackwell wrote:
>
>> On Wed, 12 Mar 2003, Till Baumgaertel wrote:
>> 
>> > how can I scale the x- and y-axis of a "plot" to the same scale?
>> >
>> > My problem: The following command sequence produces the plot in a square.
>> > What I want is the x-axis to be 5 times as wide (measured e.g. in pixels)
>> > as the y-axis is long (because y ranges from -1 to 1 and x ranges from
>0
>> > to 10).
>> 
>> It depends what graphics device you are using.  If the plot is in
>> a window on the computer screen, then resizing the window reshapes
>> the plot to whatever aspect ratio you want, interactively, so the
>> aspect ratio is not an issue.  
>
>It *is* an issue for many statistical plots which rely on interpretation
>via Euclidean distance, e.g. MDS plots.  One wants to resize and keep the
>
>aspect ratio: hence the parameter `asp', and the different resizing 
>options on the Windows graphics device.
>
>> For a hardcopy device, such as
>> postscript(), the traditional way to control the aspect ratio is
>> to fill up the rest of the page with margins.  For a nice, long
>> narrow plot ...
>> 
>> postscript("some.file.name", pointsize=11, horizontal=T)
>> par(mar=c(9.5,3.5,3,2), las=1)
>> plot(x, y, type="p")
>> 
>> 	... but after printing one test page, I always take a ruler
>> and measure the spacing of the tick marks and calculate how to
>> adjust the margin widths better.  Seriously.  I use a ruler.
>> It's clunky, but if you care about the graphical scales, that's
>> how you do it, and no complaints.  Even the difference between "A4"
>> and "letter" paper sizes would throw off any automated calculation.
>
>Not so.  The size of the plot region in inches is available from the 
>graphics parameters, specifically par("pin").
>
>-- 
>Brian D. Ripley,                  ripley at stats.ox.ac.uk
>Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>University of Oxford,             Tel:  +44 1865 272861 (self)
>1 South Parks Road,                     +44 1865 272866 (PA)
>Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>






________________________________________
Mehr Power für Ihre eMail - mit den neuen Leistungspaketen bei http://www.epost.de



More information about the R-help mailing list