Questions tagged [ggdendro]

ggdendro package is a set of tools for extracting dendrogram and tree diagram plot data for use with ggplot

ggdendro is a set of tools for extracting dendrogram and tree plot data so that dendrograms and tree plots can be plotted using the package . The ggplot philosophy is to separate clearly the data from the presentation. Unfortunately the plot method for dendrograms plots directly to a plot device without exposing the data. The package resolves this by making available functions that extract the dendrogram plot data.

The reference manual can be accessed from here.

36 questions
36
votes
4 answers

Reproducing lattice dendrogram graph with ggplot2

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 <-…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
24
votes
5 answers

Colorize Clusters in Dendogram with ggplot2

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 <-…
feder80
  • 1,195
  • 3
  • 13
  • 34
8
votes
3 answers

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

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…
Crops
  • 5,024
  • 5
  • 38
  • 65
7
votes
1 answer

ggplot2 and ggdendro - plotting color bars under the node leaves

Currently I'm using ggplot2 and ggdendro to plot dendrograms. However Now I'm in need to plot a discrete variable under the leaves along with the labels. For instance, in a publication (Zhang et al., 2006) I saw a dendrogram like this (notice th…
Einar
  • 4,727
  • 7
  • 49
  • 64
5
votes
2 answers

decrease size of dendogram (or y-axis) ggplot

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…
5
votes
1 answer

Rotate labels for ggplot dendrogram

I am trying to create a dendrogram using the package dendextend. It creates really nice gg dendrograms but unfortunately when you turn it into a "circle", the labels do not keep up. I'll provide an example below. My distance object is here:…
Brandon
  • 1,722
  • 1
  • 19
  • 32
5
votes
1 answer

R: package ggdendro plotting labels disppear

When I use the great package ggdendro to plot my tree, I come across a problem: One day, all labels of the tree it produces suddenly all disappeared. When I run the following code in my local machine and in server, I get different results. No labels…
John
  • 1,779
  • 3
  • 25
  • 53
3
votes
1 answer

Combining a ggdend tree with a geom_scatterpie

I have a phylogenetic tree: my.tree <- ape::read.tree(text = "((rat:0.06290316531,mouse:0.06094803666):0.05175420892,human:0.09883650566);") which I then convert to a ggdend object: library(dplyr) my.dend <- phylogram::as.dendrogram.phylo(my.tree)…
dan
  • 6,048
  • 10
  • 57
  • 125
2
votes
1 answer

Showing variable labels under the segments of dendrogram with ggdendro

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?…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
2
votes
1 answer

Dendrogram with labels on the right side

I want a horizontal dendrogram with the variable names on the right side to display correlation coefficients. It would be nice if I could achieve it in some ggplot2-related package, since I want the diagram to be similar looking to my other…
Zoe
  • 906
  • 4
  • 15
2
votes
1 answer

ggdendrogram : adding colored rectangles for each cluster

I am not able to add colored rectangles around the chosen clusters. library(lattice) library(permute) library(vegan) library("ggplot2") library("ggdendro") library("dendextend") data(dune) d <- vegdist(dune) csin <-…
jammah
  • 25
  • 5
2
votes
1 answer

Right align horizontal y axis titles for multiple plots using R ggplot2

I'm having trouble right aligning horizontal y axis titles for multiple plots in R ggplot2. I have a main plot which is a dendrogram with leaf labels created using the ggdendro package, and I have multiple color bars below the main plot with titles…
Ben Ernest
  • 445
  • 3
  • 14
2
votes
1 answer

R: Color branches of dendrogram while preserving the color legend

Objective: Create a dendrogram with branches colored by a factor variable with the resultant plot containing a legend to translate the branch colors to each factor variable value. I have some data with factor variables followed by the numeric data…
C. John
  • 144
  • 1
  • 15
2
votes
1 answer

Colour axis labels or draw rectangles over axis in ggplot2

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…
pachadotdev
  • 3,345
  • 6
  • 33
  • 60
2
votes
1 answer

Changing legend symbols when the guide is defined inside geom_text

Here is my data: ddata1 <- structure(list(segments = structure(list(x = c(8.203125, 1.5, 1.5, 1, 1.5, 2, 8.203125, 14.90625, 14.90625, 10.0625, 10.0625, 5.6875, 5.6875, 3.875, 3.875, 3, 3.875, 4.75, 4.75, 4, 4.75, 5.5, 5.5, 5, 5.5, 6, 5.6875,…
nouse
  • 3,315
  • 2
  • 29
  • 56
1
2 3