Is this possible to reproduce this lattice plot with ggplot2?
library(latticeExtra)
data(mtcars)
x <- t(as.matrix(scale(mtcars)))
dd.row <- as.dendrogram(hclust(dist(x)))
row.ord <- order.dendrogram(dd.row)
dd.col <- as.dendrogram(hclust(dist(t(x))))
col.ord <- order.dendrogram(dd.col)
library(lattice)
levelplot(x[row.ord, col.ord],
aspect = "fill",
scales = list(x = list(rot = 90)),
colorkey = list(space = "left"),
legend =
list(right =
list(fun = dendrogramGrob,
args =
list(x = dd.col, ord = col.ord,
side = "right",
size = 10)),
top =
list(fun = dendrogramGrob,
args =
list(x = dd.row,
side = "top",
size = 10))))

EDIT
From 8 August 2011 the
ggdendropackage is available on CRANNote also that the dendrogram extraction function is now called
dendro_datainstead ofcluster_dataYes, it is. But for the time being you will have to jump through a few hoops:
ggdendropackage (available from CRAN). This package will extract the cluster information from several types of cluster methods (includingHclustanddendrogram) with the express purpose of plotting inggplot.The code:
First load the libraries and set up the data for ggplot:
Extract dendrogram data and create the plots
Use grid graphics and some manual alignment to position the three plots on the page