问题
Possible Duplicate:
Generate multiple graphics from within an R function
I have tried to make an eps-file of a lattice plot. The .eps-file is created, but the plot seem to be blank (using 'gv'). I have been searching the inter-net for a solution, but without luck.
My code is as follows:
mydf <- data.frame(col1=c(1,1,2,2,3), col2=c(1,2,1,2,1), col3=rnorm(5))
library(lattice)
filename <- "myfile.eps"
postscript(file = filename,
width = 10, height = 10,
horizontal = FALSE, onefile = FALSE, paper = "a4")
xyplot(col3 ~ col1 | col2, data = mydf)
dev.off()
I have tried to substitute the postscript(...)
expression with
trellis.device("postscript", color = TRUE,
height = 10, width = 10,
horizontal = FALSE, onefile = FALSE, paper = "a4")
The '.eps-file' is created using both postscript(...)
and trellis.device(...)
, but seems blank looking at it with 'gv' no matter what I do.
I am greatful for any help or guidance. Sisse
回答1:
This is R FAQ 7.22: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
As indicated in comments above,
print(xyplot(co3 ~ col1 | col2, data = mydf))
should work
来源:https://stackoverflow.com/questions/9541145/r-lattice-plots-and-postscript