Re: [R] Shutting down a trellis plot (was R-help Digest, Vol 30, Issue 26)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat 27 Aug 2005 - 00:36:42 EST

I suspect you have not print()-ed your graphics, see FAQ Q7.22.

It is then possible to include dev.off() within the function. E.g.

testit <- function(fn = "test.eps")
{

   trellis.device(postscript, file=fn, onefile = FALSE, horizontal=FALSE)    print(stripplot(voice.part ~ jitter(height), data = singer, aspect = 1,

                   jitter = TRUE, xlab = "Height (inches)"))
   dev.off()
}

testit()

works for me.

On Fri, 26 Aug 2005, Jean-Marc Ottorini wrote:

> For me ( i.e. R 2.1.1 on Mac OS X), using "trellis.device
> (postscript, onefile = F, etc ..." with the lattice library within a R
> function works fine to obtain the desired graph as an EPS file ,
> provided that :
>
> 1) the command dev.off() is not included in this function
>
> 2) and it is issued at the command level after the function has
> been exited
>
> I would like to know if there is a way to close the EPS file within the
> function itself, freeing the user to issue the closing command (I
> already tried trellis.device (), and trellis.device (null) without any
> success).

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Aug 27 00:42:11 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:58:53 EST