2

I am trying to modify and tweak cluster dendrogram using dendextend, using below codes:

# prepare hierarchical cluster
hc = hclust(dist(mtcars))

dend <- as.dendrogram(hc)

dend %>% set("branches_lty", 3) %>% plot()

Please how can i set branches_lty for a specific K cluster?

Also, i want to modify and align the leave text to a give length and indent as shown in the picture.

I attach an example picture to see, i can’t achieve it with dendextend package.

NB:

I can plot it using A2Rplot, but i cant modify it. is it possible to use both?

# load code of A2R function
source("http://addictedtor.free.fr/packages/A2R/lastVersion/R/code.R")
# colored dendrogram
op = par(bg = "#EFEFEF")
A2Rplot(hc, k = 3, boxes = FALSE, col.up = "gray50", col.down = c("#FF6B6B", "#4ECDC4", "#556270"))

enter image description here

aliocee
  • 730
  • 9
  • 25
  • Hi, sorry for taking this time to answer. Please see the answer and approve it if this is indeed what you were looking for. Best, Tal. – Tal Galili Jun 03 '17 at 13:19

1 Answers1

0

You can solve this using set("branches_k_lty", k= 3), for example:

library(dendextend)
hc = hclust(dist(mtcars))
dend <- as.dendrogram(hc)
dend %>% set("branches_k_lty", k= 3) %>% plot()

enter image description here

Tal Galili
  • 24,605
  • 44
  • 129
  • 187