Hi,

I am trying to build an R application in C++ using RInside. I wanted to
save the plots as images in specified directory using codes,

png(filename = "filename", width = 600, height = 400)
xyplot(data ~ year | segment, data = dataset, layout = c(1,3),
       type = c("l", "p"), ylab = "Y Label", xlab = "X Label",
       main = "Title of the Plot")
dev.off()

It creates a png file in the specified directory if directly run from R.
But using C++ calls from RInside, I was not able to reproduce the same
result. (*I could reproduce all base plots using C++ calls. Problem with
only Lattice and ggplots*)

I used following codes as well,

myplot <- xyplot(data ~ year | segment, data = dataset, layout = c(1,3),
                 type = c("l", "p"), ylab = "Y Label", xlab = "X Label",
                 main = "Title of the Plot")
trellis.device(device = "png", filename = "filename")
print(myplot)
dev.off()

png file is getting created if I run the above code in R without any
problem. But from C++ calls, a pngfile with empty panel with title and x-y
label is getting created and not a complete plot.

I'm using the function R.parseEval() for C++ call to R.

How to get proper lattice and ggplot2 plots properly?


Thanks,

Manoj G

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to