Reputation: 1547
I have a collection of data that is hierarchical in nature, forming groups that would each be best plotted as a bar chart. If it's possible, I would love to be able to arrange a bunch of ggplot2 graphs so that they form a tree structure:
Is this something you can do with ggplot2 or supplemental package? The patchwork package seems to be the closest but doesn't allow that amount of flexibility in positioning.
Thanks!
Upvotes: 3
Views: 276
Reputation: 1005
You could use a combination of packages gridExtra
and ggplot2
. To know more details I recommander look these vignettes: Laying out multiple plots on a page and Arranging multiple grobs on a page.
require(gridExtra)
require(ggplot2)
layout <- rbind(c(NA,1,1,NA),
c(2,2,3,3))
p <- qplot(1,1)
p2 <- qplot(2,4)
p3 <- qplot(3,1)
grid.arrange(p, p2, p3, layout_matrix=layout)
Upvotes: 1