Re: [R] Note: "The default device has been opened to honour attempt to modify trellis settings"

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Wed 16 Mar 2005 - 23:33:35 EST

Luis Ridao Cruz wrote on 3/16/2005 5:16 AM:
> R-help,
>
> I'm using a function whose end result is a trellis plot.
> When I call the function I get sometimes the following message:
>
> "Note: The default device has been opened to honour attempt to modify
> trellis settings "
>
> leading up to any plot whatsoever.
>
> I call the package 'lattice' within the function and 'detach' after
> plotting.
>
> I have to close the graphics device to get the desired result (and it
> works only after a few more function calls)
>
> Here is the function code
>
> "function"<-function(somedata)
> {
> ..........
>
> library(lattice)
> trellis.par.set(theme = col.whitebg())
>
> xyplot(log.catch ~ age | yrclass , data = tmp2)
>
> detach(package:lattice)
>
> savePlot(file="catch curve",type="jpeg")
>
> }
>
> function(somedata)
>
>
> Thanks in advance.
>
> I'm running on Windows XP
>
>

>>version

>
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 0.1
> year 2004
> month 11
> day 15
> language R
>

Luis,

If you are trying to save a plot within a function, you are going about it the wrong way.

# don't call your function "function"
# "function"<-function(somedata)
my.function <- function(somedata) {

   require(lattice) # minor change here
   # next line is what's causing the message    # trellis.par.set(theme = col.whitebg())    trellis.device(jpeg, file = "catch_curve.jpg", theme = col.whitebg())    # need to explicitly print the plot to the current device    # see FAQ 7.22
   print(xyplot(log.catch ~ age | yrclass , data = tmp2))    # turn device off after printing
   dev.off()
   # not sure why you need to detach every time ...    detach(package:lattice)
   #savePlot(file="catch curve",type="jpeg") }

my.function(somedata)

--sundar



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 Wed Mar 16 23:39:55 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:48 EST