Re: [R] Splitting device for ggplots?

From: baptiste auguie <ba208_at_exeter.ac.uk>
Date: Sat, 01 Nov 2008 10:13:41 +0000

Hi,

I believe you can apply the same procedure as described in Paul Murrell's "R graphics" book for arranging lattice plots.

library(grid)
library(ggplot2)
?grid.layout

df <- data.frame(x=rnorm(100), y=rnorm(100)) df2 <- data.frame(x <- rnorm(100), y=runif(x))

p <- qplot(x,y, data=df)
p2 <- qplot(x,y, data=df2)

pushViewport(viewport(x=0.25, width = 0.5, height = 0.8, angle = 0, name = "leftvp"))
grid.rect(gp = gpar(col = rgb(43/255, 140/255, 190/255))) print(p, newpage=F)
upViewport()
pushViewport(viewport(x=0.75, width = 0.5, height = 0.8, angle = 0, name = "rightvp"))
grid.rect(gp = gpar(col = rgb(43/255, 140/255, 190/255))) print(p2, newpage=F)
upViewport()

Hope this helps,

baptiste

On 1 Nov 2008, at 09:35, Vitalie Spinu wrote:

> Dear UseRs,
>
> For various reasons I need to plot multiple ggplots on one device
> (preferably pdf). Is there a way to achieve that?
> par(mfrow), split.screen() and layout() seem not to do the job.
>
> Thanks,
> Vitalie.
>
> ______________________________________________
> 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.


Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag



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 Sat 01 Nov 2008 - 10:18:55 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 Sat 01 Nov 2008 - 15:30:21 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