I obtained a series of pictures with R and I want to save these pictures as pdf. However, I want to save these pictures in several separate pages instead of one page. What should I do?
After opening a PDF device, simply make serial calls to the plots. Each new plot will create a new page in the PDF file.
Example (not working by copy&paste, just for illustration):
pdf(...)
plot(y~x)
boxplot(df)
hist(y)
dev.off()
will create a pdf with 3 pages and a scatterplot on page 1, a boxplot on page 2 and a histogram on page 3.
EDIT:
The parameter "onefile" should be set to FALSE, what is the default. If this is not changed to TRUE and if the file is not a pipe, multiple pages will be created. Please have a look at the help page (?pdf):
onefile: logical: if true (the default) allow multiple figures in one file. If false, generate a file with name containing the page number for each page. Defaults to TRUE, and forced to true if file is a pipe.
After opening a PDF device, simply make serial calls to the plots. Each new plot will create a new page in the PDF file.
Example (not working by copy&paste, just for illustration):
pdf(...)
plot(y~x)
boxplot(df)
hist(y)
dev.off()
will create a pdf with 3 pages and a scatterplot on page 1, a boxplot on page 2 and a histogram on page 3.
EDIT:
The parameter "onefile" should be set to FALSE, what is the default. If this is not changed to TRUE and if the file is not a pipe, multiple pages will be created. Please have a look at the help page (?pdf):
onefile: logical: if true (the default) allow multiple figures in one file. If false, generate a file with name containing the page number for each page. Defaults to TRUE, and forced to true if file is a pipe.
@Jochen Wilhelm :great thanks for your detailed answer. a question added, if I want to save pictures which are generated in one operation(eg MA plot for 56 cel files),how can I save these pictures with several pages
Nan, this is written in the help. Set the argument "onefile=FALSE". You can use "%d" in the filename to indicate a position wher the plot number is placed. Another way is to create and close separate plots in a loop, for example