I have recently been acquainted ggplot2, which I like very much.
I am producing a plot intended for submission. It’s a 2 by 2 grid of plots written to a pdf file. To that end I am using the code as explained on page 154 of the ggplot2 book, i.e.,
# this is just test data:
x = 1:20
y = 1 + 2*x+rnorm(20)
mydata = as.data.frame(cbind(x,y))
(a = qplot(x,y,data=mydata, main = "Figure 1(a)", xlab = "Delta", ylab = "Relative MSE") )
(b = qplot(x,y,data=mydata, main = "Figure 1(b)", xlab = "Delta", ylab = "Relative MSE") )
(c = qplot(x,y,data=mydata,main = "Figure 1(c)", xlab = "Delta", ylab = "Relative MSE") )
(d =qplot(x,y,data=mydata,main = "Figure 1(d)", xlab = "Delta", ylab = "Relative MSE") )
pdf("Figure1.pdf", width = 8, height =8, title = This is Figure 1")
grid.newpage()
pushViewport(viewport(layout = grid.layout(2,2)))
vplayout = function(x,y)
viewport(layout.pos.row = x, layout.pos.col = y)
print(a,vp = vplayout(1,1))
print(b,vp = vplayout(1,2))
print(c,vp = vplayout(2,1))
print(d,vp = vplayout(2,2))
dev.off()
I would like also to add a main title to the page. How is that done?
Thanks for your help,
Ori
Ori Davidov
Department of Statistics
Univesity of Haifa
Hadley
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
Try this,
library(gridExtra)
## default:
## combined <- grid.arrange(a, b, c, d, main = "This is Figure 1")
large_title <- textGrob("This is Figure 1", gp=gpar(fontsize=18, col="red"))
combined <- arrangeGrob(a, b, c, d, main = large_title)
ggsave(combined, file="Figure1.pdf", width = 8, height =8)
HTH,
baptiste