ggdendro

decrease size of dendogram (or y-axis) ggplot

♀尐吖头ヾ 提交于 2019-12-12 19:12:11
问题 I have this code for a dendrogram. How can I decrease the size of dendrogram (or y-axis)? I am using this code as example. In my dataset, I have large labels so I do not have space enough to include it. For that reason, I would like to reduce the space used for y axis, decrease the distance between 0 and 150. Also, when I save the figure as tiff, most of figure is the dendogram and I can not see labels clearly. df <- USArrests # really bad idea to muck up internal datasets labs <- paste("sta_

Equally spaced out lengths in dendrograms [closed]

女生的网名这么多〃 提交于 2019-12-12 03:07:00
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . In this diagram, the main information (most nodes) is on the extreme left side. I want to make the dendrogram easy to read and thus the edges should be proportionally long. Any specific arguments to be used or is it just the data's problem? 回答1: Package ape has an option for plotting a tree (or

Colour axis labels or draw rectangles over axis in ggplot2

ⅰ亾dé卋堺 提交于 2019-12-11 01:58:22
问题 I want to create a beautiful dendrogram by using ggplot2. This is a reproducible example of what I'm doing: library(ggplot2) library(ggdendro) data(mtcars) x <- as.matrix(scale(mtcars)) dd.row <- as.dendrogram(hclust(dist(t(x)))) mtcars_dendrogram <- ggdendrogram(dd.row, rotate = TRUE, theme_dendro = FALSE) + labs(x="", y="Distance") + ggtitle("Mtcars Dendrogram") + theme(panel.border = element_rect(colour = "black", fill=NA, size=.5), axis.text.x=element_text(colour="black", size = 10), axis

Showing variable labels under the segments of dendrogram with ggdendro

荒凉一梦 提交于 2019-12-06 10:26:07
问题 My question is related to Andrie's answer to my earlier question. My question is whether is this possible to display the variable labels and car label under the corresponding segments of the dendrogram? library(ggplot2) library(ggdendro) data(mtcars) x <- as.matrix(scale(mtcars)) dd.row <- as.dendrogram(hclust(dist(t(x)))) ddata_x <- dendro_data(dd.row) p2 <- ggplot(segment(ddata_x)) + geom_segment(aes(x=x0, y=y0, xend=x1, yend=y1)) print(p2) 回答1: Make sure you have version 0.0-7 of ggdendro

Showing variable labels under the segments of dendrogram with ggdendro

社会主义新天地 提交于 2019-12-04 17:39:14
My question is related to Andrie's answer to my earlier question. My question is whether is this possible to display the variable labels and car label under the corresponding segments of the dendrogram? library(ggplot2) library(ggdendro) data(mtcars) x <- as.matrix(scale(mtcars)) dd.row <- as.dendrogram(hclust(dist(t(x)))) ddata_x <- dendro_data(dd.row) p2 <- ggplot(segment(ddata_x)) + geom_segment(aes(x=x0, y=y0, xend=x1, yend=y1)) print(p2) Make sure you have version 0.0-7 of ggdendro and then use the convenience function ggdendrogram : library(ggplot2) library(ggdendro) ggdendrogram(dd.row)

Tree cut and Rectangles around clusters for a horizontal dendrogram in R

 ̄綄美尐妖づ 提交于 2019-11-29 03:07:56
问题 I am trying to plot the results of a hierarchical clustering in R as a dendrogram, with rectangles identifying clusters. The following code does the trick for a vertical dendrogram, but for a horizontal dendrogram, ( horiz=TRUE ), the rectangles are not drawn. Is there any way to do the same for horizontal dendrograms too. library("cluster") dst <- daisy(iris, metric = c("gower"), stand = FALSE) hca <- hclust(dst, method = "average") plot(as.dendrogram(hca), horiz = FALSE) rect.hclust(hca, k

Colorize Clusters in Dendogram with ggplot2

十年热恋 提交于 2019-11-27 01:36:30
问题 Didzis Elferts showed how to plot a dendogram using ggplot2 and ggdendro: horizontal dendrogram in R with labels here is the code: labs = paste("sta_",1:50,sep="") #new labels rownames(USArrests)<-labs #set new row names hc <- hclust(dist(USArrests), "ave") library(ggplot2) library(ggdendro) #convert cluster object to use with ggplot dendr <- dendro_data(hc, type="rectangle") #your own labels are supplied in geom_text() and label=label ggplot() + geom_segment(data=segment(dendr), aes(x=x, y=y

Reproducing lattice dendrogram graph with ggplot2

守給你的承諾、 提交于 2019-11-26 23:53:17
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 =

Reproducing lattice dendrogram graph with ggplot2

好久不见. 提交于 2019-11-26 12:21:01
问题 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,