[R] Plot to postscript in function

Marco Albani malbani at fas.harvard.edu
Tue Jan 28 18:25:03 CET 2003


Hello,

I am having problems with plotting to a postscript device within a 
function call.

When I do the same thing line by line in the command line interface, I 
have no problems, but the function creates an empty postscript file.
If I remove the dev.off() call at the end of the function, I get one of 
the plots (the last), but not the others.

Is there any way to get around this problem, or a better way to have R 
plot a series of diagnostic graphics from a dataframe with a singe 
command? Sounds like a general enough problem, but I have found no 
answers with my Google searches

R.version:
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
status
major    1
minor    5.0
year     2002
month    04
day      29
language R

the function is

BbEh.graphs2eps <- function(the.data){

#function to plot all sort of information to
#a single eps file for storage and future printing or display
#does not work because of laz evaluation?

filename <- deparse(substitute(the.data))
thefile <- paste(c("../ed/",filename,"/",filename,".eps"),collapse = "")
postscript(file= thefile, paper = "letter")
lset(my.lts)

#plot cohort variables
BbEh.xyplot.dbh(the.data) #these are custom lattice plotting functions
BbEh.xyplot.h(the.data)
BbEh.xyplot.bl(the.data)
BbEh.xyplot.bs(the.data)
BbEh.xyplot.dens(the.data)

#plot allometry checks
BbEh.xyplot.hVSdbh(the.data)
BbEh.xyplot.bdVSdbh(the.data)
BbEh.xyplot.blVSdbh(the.data)
BbEh.xyplot.bdVSh(the.data)

dev.off(dev.cur())


}

-- 
Marco Albani, Ph.D.
Postdoctoral Fellow
Dept. of Organismic and Evolutionary Biology
Harvard University
HUH 22 Divinity Avenue
Cambridge, MA
02138-2094 USA

Tel: +1 617 495 1621
Fax: +1 617 495 9484

http://www.people.fas.harvard.edu/~malbani




More information about the R-help mailing list