library(ggplot2)
p <- ggplot(data = diamonds, aes(x = clarity, fill = cut))
p1 <- p + geom_histogram(postition = "stack") + scale_y_continuous(breaks = seq(0,
12000, 2000))
p2 <- p + geom_histogram(position = "fill")
p3 <- p + geom_histogram(position = "dodge")
grid.newpage()
pushViewport(viewport(layout = grid.layout(2, 2)))
vplayout = function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
print(p1, vp = vplayout(1, 1))
print(p2, vp = vplayout(1, 2))
print(p3, vp = vplayout(2, 1:2))