I am switching from ggplot2 1.0.1 and gridExtra 0.9.1 to the newest versions of these packages and struggle with some minor issues at the moment.
One problem is the title in a combined plot.
library(ggplot2)
library(gridExtra)
df <- data.frame(x=runif(100), y=runif(100))
p1 <- ggplot(df, aes(x,y)) + geom_point()
p2 <- ggplot(df, aes(x,y)) + geom_point()
a <- arrangeGrob(p1,p1,p2, layout_matrix=rbind(c(1,2),c(1,3)), top='my title')
plot(a)
ggsave('a.pdf', a)
in the older version, the parameter was called main and I had to use print to plot my graphics a. Now, when I save the graph, everything is fine. But the plot(a) graph has the light grey grid background behind the my title. In the saved pdf file, the background is white again.
I also tried to use grid.arrange but I don't want to print the plot directly when executing. Thats why I use the two step approach by saving the graph in a variable and then plot it.
So, how do I get a white background when plot(a)?
Use grid.draw. The plot method is for testing only.
library(grid)
grid.newpage()
grid.draw(a)

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With