With the code found at https://gist.github.com/low-decarie/5886616 A dual dendodogram tile plot can be produced:
dual_dendogram_tile_plot(as.matrix(USArrests), main="USA Arrests")
The problem: Align the vertical dendogram with the tile plot area. (and/or improve the alignment of the horizontal dendogram)
This question relates to:
left align two graph edges (ggplot)
Specifying ggplot2 panel width
Plot correlation matrix into a graph
Here's an example to align more basic grobs,
library(ggplot2)
library(grid)
library(gtable)
p <- qplot(1,1)
g <- ggplotGrob(p)
panel_id <- g$layout[g$layout$name == "panel",c("t","l")]
g <- gtable_add_cols(g, unit(1,"cm"))
g <- gtable_add_grob(g, rectGrob(gp=gpar(fill="red")),
t = panel_id$t, l = ncol(g))
g <- gtable_add_rows(g, unit(1,"in"), 0)
g <- gtable_add_grob(g, rectGrob(gp=gpar(fill="blue")),
t = 1, l = panel_id$l)
grid.newpage()
grid.draw(g)
and with your grobs
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