Re: [R] asp and ylim

From: Martin Maechler <>
Date: Mon, 21 Jul 2008 15:54:51 +0200

>>>>> "DE" == David Epstein <> >>>>> on Mon, 21 Jul 2008 14:32:47 +0100 writes:

    DE> A really great answer to my concerns! I'll get hold of the Paul     DE> Murrell book, and see how far I can get.

    DE> On 21 Jul, 2008, at 10:48, Martin Maechler wrote:
>> Play around resizing your graphics window..
>> This is very instructive, with an 'asp = .' using "traditional
>> graphics" plot().
    DE> OK, but I don't know what you mean by "asp=.". Does this mean setting     DE> asp equal to NULL, or to a default setting?

I meant *any* value
such as your example's asp = 1

    DE> Perhaps the best solution is to live with plot() as it
    DE> is. If I need the picture for a paper, I will export
    DE> data to Matlab or Mathematica or Illustrator, where I
    DE> can get the control I want.

>> Hah, you must be kidding!

    DE> Change "kidding" to "frustrated"!

well... ... your choice :-)

>> For a "paper plot", e.g., pdf() as I'd recommend nowadays,
>> you can set the device region by 'width' and 'height' ;
>> and if you really want to use "traditional graphics" here, do
>> something like
>> ## modified by MM from David Epstein's original example
>> myplot <- function(y, yb = mean(y), ylim = c(-1,1)) {
>> ybarv <-, length(y))
>> x <- seq_along(y)
>> plot(x,y, asp=1, xlab="position",ylab="ybar", type="n", ylim =
>> ylim)
>> abline(h = ybar)## instead of segments(x[1], ybar, x[ylength],
>> ybar)
>> segments(x, ybarv, x,y)
>> points (x, ybarv, pch=21, bg="white")
>> points (x, y, pch=19, col="black")
>> invisible()
>> }
    DE> I learned quite a few things from this code above.

>> y <- c(1.21, 0.51, 0.14, 1.62, -0.8,
>> 0.72, -1.71, 0.84, 0.02, -0.12)
>> myplot(y)

      ## MM: setting device region so that  ylim = c(-1,1)  "about fits""asp-ex.pdf", height= 3.3, width=10)

    DE> I cannot find the functions and pdf.end. Are these part of     DE> some package that I need to load? Your package?

Oh, that's been an "accident" :
They are part of 'sfsmisc' (a small R-code only package you can quickly install and load) and I use them all the time, but really, I've wanted to just use

 pdf("asp-ex.pdf", height= 3.3, width=10)  myplot(y)
 ## and now view the pdf file in your favorite viewer


    DE> Thanks
    DE> David mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 21 Jul 2008 - 13:59:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 Jul 2008 - 14:32:01 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive