Hi,
I was trying to create a dendrogram using ggplot2. Everything seems to be
looking ok except that the text labels are too close to the dendrogram (in
the example below, 'a','b', ..). Is there a way that I can put a
little gap
between where the dendrogram ends and the label begins?
thanks!!
===================== code =================
library(ggplot2)
mat <- matrix(sample(1:1000,180),12,15)
rownames(mat) <- letters[1:12]
colnames(mat) <- paste('c',1:15,sep='')
dates <- sample(1:3,12,replace=T)
hc <- hclust(dist(mat))
order <- hc$order
batch <- as.factor(as.numeric(dates[order])) ## batchorder
roworder <- rownames(mat)[order]
dd.row <- as.dendrogram(hc)
ddata_x <- dendro_data(dd.row)
labs <- label(ddata_x)
labs2 <- cbind(labs,batch,roworder)
p2 <- ggplot(segment(ddata_x)) +
geom_segment(aes(x=x, y=y, xend=xend, yend=yend)) + coord_flip() +
scale_y_reverse(expand=c(0.2, 0)) +
theme_dendro()
p2 + geom_text(data=labs2,
aes(label=roworder, x=x, y=0, colour=batch),size=4)
===================================
[[alternative HTML version deleted]]