[R] asp and ylim

David Epstein David.Epstein at warwick.ac.uk
Mon Jul 21 15:32:47 CEST 2008


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

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().
OK, but I don't know what you mean by "asp=.". Does this mean setting  
asp equal to NULL, or to a default setting?

>     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!

Change "kidding" to "frustrated"!

> 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 <- rep.int(yb, 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()
> }
>
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"
> pdf.do("asp-ex.pdf", height= 3.3, width=10)
> myplot(y)
> pdf.end()

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

Thanks
David



More information about the R-help mailing list