baptiste / gridExtra

Miscellaneous Functions for "Grid" Graphics
http://cran.r-project.org/web/packages/gridExtra/index.html
15 stars 4 forks source link

arrange.grob Main Title is Placed Below Plots #23

Closed DarioS closed 9 years ago

DarioS commented 9 years ago

The title is wrongly placed and the number of rows is ignored.

library(grid)
library(gridExtra)
library(ggplot2)

valuesHealty <- rnorm(20, 10, 2)
valuesSick <- rnorm(20, 5, 2)
plotData <- data.frame(measure = c(valuesHealty, valuesSick), group = rep(c("healthy", "sick"), each = 20))

densPlot <- ggplot(plotData, aes(x = measure, colour = group)) + stat_density(aes(y = ..density..), geom = "path", position = "identity")
boxPlot <- ggplot(plotData, aes(x = group, y = measure)) + geom_boxplot()

grid.arrange(densPlot, boxPlot, nrow = 2) # Fine
grid.arrange(densPlot, boxPlot, nrow = 2, main = textGrob("Comparisons")) # Problem
baptiste commented 9 years ago

the main argument has been renamed top in the latest version