Re: [R] multiple plots per page using hist and pdf

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Wed, 27 Feb 2008 18:28:03 -0500 (EST)


I think you need to reset the par(mfrow=c(2,2)) before plotting the second set of graphs.

> Hello,
>
> I am puzzled by the behavior of hist() when
> generating multiple plots
> per page on the pdf device. In the following example
> two pdf files
> are generated. The first results in 4 plots on one
> pdf page as
> expected. However, the second, which swaps one of
> the plot() calls
> for hist(), results in a 4 page pdf with one plot
> per page.
>
> How might I get the histogram with 3 other scatter
> plots onto a
> single pdf page?
>
> platform powerpc-apple-darwin8.10.1
> version.string R version 2.6.1 (2007-11-26)
>
> Thanks!
> Ben
>
> ###BEGIN
> data(iris)
>
> orig.par = par(no.readonly = TRUE)
>
> pdf(file = "just_plots.pdf")
>
> par(mfrow=c(2,2))
>
> plot(iris$Sepal.Length, iris$Sepal.Width, main =
> "Plot 1")
> plot(iris$Petal.Length, iris$Petal.Width, main =
> "Plot 2")
> plot(iris$Sepal.Length, iris$Petal.Length, main =
> "Plot 3")
> plot(iris$Sepal.Width, iris$Petal.Width, main =
> "Plot 4")
>
> dev.off()
>
> pdf(file = "hist_and_plots.pdf")
>
> hist(iris$Sepal.Length, main = "Plot 1")
> plot(iris$Petal.Length, iris$Petal.Width, main =
> "Plot 2")
> plot(iris$Sepal.Length, iris$Petal.Length, main =
> "Plot 3")
> plot(iris$Sepal.Width, iris$Petal.Width, main =
> "Plot 4")
>
> dev.off()
>
>
> par(orig.par)
> ###END
>
> Ben Tupper
> PemaquidRiver_at_tidewater.net
>
> I GoodSearch for Ashwood Waldorf School.
>
> Raise money for your favorite charity or school just
> by searching the
> Internet with GoodSearch - www.goodsearch.com -
> powered by Yahoo!
>
> ______________________________________________
> R-help_at_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.
>



R-help_at_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. Received on Wed 27 Feb 2008 - 23:30:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Feb 2008 - 00:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive