albertosantini / node-rio

Integration with Rserve, a TCP/IP server for R framework
https://github.com/albertosantini/node-conpa
MIT License
176 stars 35 forks source link

Lattice xyplot() renders only white background #25

Closed chrislarsenqlik closed 9 years ago

chrislarsenqlik commented 9 years ago

Hi, This is probably not an "issue" but more of a general question about Rio's (RServe's?) capabilities. I am trying to use a lattice graphic saved as .png using the ex5.R example but when using lattice it saves as a white-only image. plot(1:10) works fine for me. Here is the ex5.R script I'm trying to use, which does work in my R Console..

createDummyPlot <- function () {
    filename <- tempfile("plot", fileext = ".png")

    png(filename)
    library(lattice)
    state <-data.frame(state.x77,region=state.region)
    xyplot(Life.Exp ~ Income | region, data = state, layout = c(4,1))
    dev.off()

    image <- readBin(filename, "raw", 29999)
    unlink(filename)

    image
}

Thanks in advance, Chris

albertosantini commented 9 years ago

This behavior is a FAQ for lattice commands. http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

createDummyPlot <- function () {
    library(lattice)

    filename <- tempfile("plot", fileext = ".png")

    state <-data.frame(state.x77,region=state.region)
    tmp <- xyplot(Life.Exp ~ Income | region, data = state, layout = c(4,1))
    png(filename)
    print(tmp)
    dev.off()

    image <- readBin(filename, "raw", 29999)
    unlink(filename)

    image
}
chrislarsenqlik commented 9 years ago

Aha! Thanks