Hi, R members. I want to save plots. So I use the R as fallows : -------------------------------- a <- c(1,10) b <- c(1,10) c <- c(2,20) d <- c(2,20) require(lattice) trellis.device("bmp", file = "test.bmp", bg = "white") print(plot(a,b)) print(plot(c,d)) dev.off() -------------------------------- However, I got a image of plot(c,d). I want to get a image of plot(a,b) and plot(c,d). Can anyone suggest a solution? Thanks. Hee-Jeong. [[alternative HTML version deleted]]
If you want to save both figures in the same file and if PDF is acceptable, try this: a <- c(1,10) b <- c(1,10) c <- c(2,20) d <- c(2,20) library(lattice) # require is design for use inside functions pdf("test.pdf") trellis.device(new = FALSE, col = TRUE, bg = "white") plot(a,b) plot(c,d) dev.off() hope this helps, Chuck ??? wrote:> I want to save plots. So I use the R as fallows : > -------------------------------- > a <- c(1,10) > b <- c(1,10) > c <- c(2,20) > d <- c(2,20) > require(lattice) > trellis.device("bmp", file = "test.bmp", bg = "white") > print(plot(a,b)) > print(plot(c,d)) > dev.off() > -------------------------------- > > However, I got a image of plot(c,d). > I want to get a image of plot(a,b) and plot(c,d). > > Can anyone suggest a solution?-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
On Tue, 18 May 2004, Chuck Cleland wrote:> If you want to save both figures in the same file and if PDF is > acceptable, try this:and if it is not, ?bmp will tell you how to specify the file= in a way that you will get 2 .bmp files.> > a <- c(1,10) > b <- c(1,10) > c <- c(2,20) > d <- c(2,20) > library(lattice) # require is design for use inside functions > > pdf("test.pdf") > trellis.device(new = FALSE, col = TRUE, bg = "white")# trellis.device is designed for lattice plots, so not needed here.> plot(a,b) > plot(c,d) > dev.off() > > hope this helps, > > Chuck > > ??? wrote: > > I want to save plots. So I use the R as fallows : > > -------------------------------- > > a <- c(1,10) > > b <- c(1,10) > > c <- c(2,20) > > d <- c(2,20) > > require(lattice) > > trellis.device("bmp", file = "test.bmp", bg = "white") > > print(plot(a,b)) > > print(plot(c,d)) > > dev.off() > > -------------------------------- > > > > However, I got a image of plot(c,d). > > I want to get a image of plot(a,b) and plot(c,d). > > > > Can anyone suggest a solution? > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
> Hi, R members. > > I want to save plots. So I use the R as fallows : > -------------------------------- > a <- c(1,10) > b <- c(1,10) > c <- c(2,20) > d <- c(2,20) > require(lattice) > trellis.device("bmp", file = "test.bmp", bg = "white") > print(plot(a,b)) > print(plot(c,d)) > dev.off() > -------------------------------- > > However, I got a image of plot(c,d). > I want to get a image of plot(a,b) and plot(c,d).What happens when you type the above without "trellis.device(...)" and "dev.off()". Does that look like the plot you wrote to file? R is one of those funny software tools that does what you tell it. 1) "plot()" isn't a lattice function, so using the function "bmp(file "test.bmp", bg = "white")" instead of "trellis.device()" is safer. 2) you haven't told R that you want two plots on one page, nor how you want to arrange them. See ?layout and ?par. On the par help page, pay careful attention to the mfcol and mfrow arguments. 3) type "help.start()", and follow the link to "An Introduction to R", particularly the graphics section. Then play with this. par(mfcol=c(2,1)) plot(a,b) plot(c,d) Have fun! Jason