[Rd] possible bug: dev.copy / could not find any X11 fonts

Tamas K Papp tpapp at Princeton.EDU
Wed Jan 31 15:50:39 CET 2007


Hi,

I am experiencing something strange, and thought I would ask before
reporting a bug.  I trimmed it down to a self-contained example,
attached as an R file.  The purpose of the functions is to save the
plots into a ps file and simultaneously plot them on an x11 device,
but don't open a new one if there is already one opened (I don't want
the repositioning / flicker).

When running the code:

> source("plotf.r")
> plotf(avc,1)
Error in dev.copy(which = x11dev) : could not find any X11 fonts
Check that the Font Path is correct.

The error message reappears whenever I switch to the plot window.  A
partial plot is in the x11 window.

When called in other contexts, plotting functions work perfectly, so I
don't see what the problem is.

Thanks,

Tamas


version information:
               _                           
platform       i486-pc-linux-gnu           
arch           i486                        
os             linux-gnu                   
system         i486, linux-gnu             
status                                     
major          2                           
minor          4.1                         
year           2006                        
month          12                          
day            18                          
svn rev        40228                       
language       R                           
version.string R version 2.4.1 (2006-12-18)
-------------- next part --------------
a <- 1:5
avc <- list(v=a,cons=a,saving=a)

findx11dev <- function(create=TRUE) {
  devices <- dev.list()
  x11dev <- which(names(devices)=="X11")
  if (length(x11dev)==0) {
    if (create) {
      x11()
      dev.cur()
    } else {
      NULL
    }
  } else {
    devices[tail(x11dev,1)]
  }
}

plotf <- function(avc,k,...) {
  plotm <- function(m, ...)
    plot(1:5,m,type="l",...)
  ## open ps device
  postscript(sprintf("plot-%03d.eps",k))
  psdev <- dev.cur()
  dev.control("enable")
  ## plot
  layout(1:3)
  plotm(avc$v, main="value", ylab="v")
  plotm(avc$cons, main="consumption", ylab="c")
  plotm(avc$saving, main="saving", ylab="s")
  ## copy & close ps device
  x11dev <- findx11dev()
  dev.set(psdev)
  dev.copy(which=x11dev)
  dev.off(psdev)  
}


More information about the R-devel mailing list