R lattice plots and postscript [duplicate]

為{幸葍}努か 提交于 2019-12-11 07:59:21

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!