Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ggdendrogram

Creates dendrogram plot using ggplot.


Description

This is a convenience function

Usage

ggdendrogram(
  data,
  segments = TRUE,
  labels = TRUE,
  leaf_labels = TRUE,
  rotate = FALSE,
  theme_dendro = TRUE,
  ...
)

Arguments

data

Either a dendro object or an object that can be coerced to class dendro using the dendro_data() function, i.e. objects of class dendrogram, hclust or tree

segments

If TRUE, show line segments

labels

if TRUE, shows segment labels

leaf_labels

if TRUE, shows leaf labels

rotate

if TRUE, rotates plot by 90 degrees

theme_dendro

if TRUE, applies a blank theme to plot (see theme_dendro())

...

other parameters passed to ggplot2::geom_text()

Value

See Also

Examples

### Demonstrate ggdendrogram

library(ggplot2)
hc <- hclust(dist(USArrests), "ave")

# Demonstrate plotting directly from object class hclust
p <- ggdendrogram(hc, rotate = FALSE)
print(p)
ggdendrogram(hc, rotate = TRUE)

# demonstrate converting hclust to dendro using dendro_data first
hcdata <- dendro_data(hc)
ggdendrogram(hcdata, rotate = TRUE, size = 2) + 
  labs(title = "Dendrogram in ggplot2")

ggdendro

Create Dendrograms and Tree Diagrams Using 'ggplot2'

v0.1.22
GPL-2 | GPL-3
Authors
Andrie de Vries [aut, cre], Brian D. Ripley [aut] (author of package tree)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.