[R] Question from Newbie on PostScript and Multiple Plots

Marc Schwartz MSchwartz at MedAnalytics.com
Fri Aug 13 18:48:15 CEST 2004


On Fri, 2004-08-13 at 11:28, Johnson, Heather wrote:
> Hi,
>  
> As I'm pretty new to R I hope this question isn't too basic.  
>  
> I am currently looping through my dataset and for each iteration am
> producing three separate plots.  When I output these plots to the screen
> they are nicely grouped as three plots per page, however, when I try to send
> it to a PostScript file I get one page for each plot.  I have adjusted my
> postscript options so that my plots are the size that I want and the paper
> is set to portrait, I just can't figure out how to get all three plots on
> one page in the postscript file.  I've been through the archives on the list
> (albeit not exhaustively) and the manuals available on the R site and cannot
> figure out how to solve my problem.
>  
> Thanks,
> -Heather


Either one of the following work for me:

# Do 3 plots in a 2 x 2 matrix
postscript(file = "ThreePlots.ps", horizontal = FALSE)
par(mfrow = c(2, 2))
plot(1:5)
barplot(1:5)
boxplot(rnorm(10))
dev.off()

# Do 3 x 1
postscript(file = "ThreePlots.ps", horizontal = FALSE)
par(mfrow = c(3, 1))
plot(1:5)
barplot(1:5)
boxplot(rnorm(10))
dev.off()

Can you provide an example of the code that you are using?

Marc Schwartz




More information about the R-help mailing list