An alternative would be to use the arrangeGrob function of the gridExtra
package to generate the final montage, and then use ggsave:

figure1<-arrangeGrob(plot1,plot2,ncol=2)
ggsave(...)

Best regards

Nelson



On Thu, Jun 19, 2014 at 8:45 AM, ONKELINX, Thierry <thierry.onkel...@inbo.be
> wrote:

> 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)
> dev.off()
>
> 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
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> thierry.onkel...@inbo.be
> www.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-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Adam Hayward
> Verzonden: woensdag 18 juni 2014 21:18
> Aan: r-help@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.
>
> plot1<-ggplot(.........)
> plot2<-ggplot(.........)
> 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
>
>
>
> --
> Adam Hayward
> Post-Doctoral Research Associate, University of Sheffield
> http://adhayward.wordpress.com/
> https://twitter.com/adhayward18
>
> Department of Animal and Plant Sciences
> Alfred Denny Building
> University of Sheffield
> Western Bank
> Sheffield S10 2TN
> UK
> http://www.huli.group.shef.ac.uk/adam-personal.html
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
> * * * * * * * * * * * * * 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.
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to