[R] Publication-ready figures with two plots

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Jun 19 09:45:06 CEST 2014

Dear Adam,

ggsave() works only with single ggplot object. You need the standard R way of saving those plots.
1) open a suitable device
2) plot the figures
3) close the device

tiff(filename = "Figure 1.tiff", scale = 1, width = 10, height = 5, units = "cm", dpi = 300)
grid.arrange(plot1, plot2, ncol=2)

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org] Namens Adam Hayward
Verzonden: woensdag 18 juni 2014 21:18
Aan: r-help op r-project.org
Onderwerp: [R] Publication-ready figures with two plots

Hi all,

I have quite a specific problem with producing 300ppi plots in tiff format for publication. I have found ggsave to work beautifully with a single plot, which can then be exported to GIMP to compress the resulting large tiff file. However, it seems to run into trouble when plotting two figures next to each other, e.g.

grid.arrange(plot1, plot2, ncol=2)

ggsave(filename = "Figure 1.tiff", scale = 1, width = 10, height = 5, units = "cm", dpi = 300)

This results in only plot2 appearing in the resulting tiff file, with plot
1 nowhere to be seen.

I will also have a figure which does not use ggplot, but consists of three plots produced with barplot2 and matplot, but presumably this faces a similar problem. Essentially, could anyone suggest a way of translating what appears in the plot appearing in the plot window (I use RStudio) to a high-resolution tiff file with as little fuss as possible?

Many thanks,


Adam Hayward
Post-Doctoral Research Associate, University of Sheffield http://adhayward.wordpress.com/

Department of Animal and Plant Sciences
Alfred Denny Building
University of Sheffield
Western Bank
Sheffield S10 2TN

        [[alternative HTML version deleted]]

R-help op r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.

More information about the R-help mailing list