Hi, I was trying to use par(mfrow) to put 4 heatmaps on a single page. However, I get one plot per page and not one page with 4 plots. What should I modify? Test code is given below: test = matrix(rnorm(60), 20, 3) pdf(file='test.pdf',width=10,height=8) par(mfrow=c(2,2)) heatmap(test) heatmap(test) heatmap(test) heatmap(test) dev.off() thanks! [[alternative HTML version deleted]]
Dear Brian If you look at ?heatmap and the second paragraph of the Note you will see that it is behaving according to its documentation. On 23/07/2017 13:11, Brian Smith wrote:> Hi, > > I was trying to use par(mfrow) to put 4 heatmaps on a single page. However, > I get one plot per page and not one page with 4 plots. What should I > modify? Test code is given below: > > test = matrix(rnorm(60), 20, 3) > > pdf(file='test.pdf',width=10,height=8) > par(mfrow=c(2,2)) > heatmap(test) > heatmap(test) > heatmap(test) > heatmap(test) > dev.off() > > thanks! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > > --- > This email has been checked for viruses by AVG. > http://www.avg.com > >-- Michael http://www.dewey.myzen.co.uk/home.html
The answer is "don't do that" because that function abuses par. Use lattice or ggplot2 with grid graphics to plot multiple heatmaps. https://stackoverflow.com/questions/15114347/to-display-two-heatmaps-in-same-pdf-side-by-side-in-r -- Sent from my phone. Please excuse my brevity. On July 23, 2017 5:11:32 AM PDT, Brian Smith <bsmith030465 at gmail.com> wrote:>Hi, > >I was trying to use par(mfrow) to put 4 heatmaps on a single page. >However, >I get one plot per page and not one page with 4 plots. What should I >modify? Test code is given below: > >test = matrix(rnorm(60), 20, 3) > >pdf(file='test.pdf',width=10,height=8) >par(mfrow=c(2,2)) >heatmap(test) >heatmap(test) >heatmap(test) >heatmap(test) >dev.off() > >thanks! > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.
Hi If you are really wedded to heatmap(), you could also use 'gridGraphics', something like this ... library(gridGraphics) grid.newpage() pushViewport(viewport(0, .5, .5, .5, just=c("left", "bottom"))) grid.echo(function() { heatmap(test) }, newpage=FALSE) popViewport() pushViewport(viewport(.5, 0, .5, .5, just=c("left", "bottom"))) grid.echo(function() { heatmap(test) }, newpage=FALSE) popViewport() Paul On 24/07/17 01:12, Jeff Newmiller wrote:> The answer is "don't do that" because that function abuses par. Use lattice or ggplot2 with grid graphics to plot multiple heatmaps. > > https://stackoverflow.com/questions/15114347/to-display-two-heatmaps-in-same-pdf-side-by-side-in-r >-- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/