talgalili / dendextend

Extending R's Dendrogram Functionality
152 stars 28 forks source link

overlapping branches in ggplot radial dendrogram #81

Open andreasleha opened 6 years ago

andreasleha commented 6 years ago

when creating a radial dendrogram via coord_polar the first and last leave collide (by default) at the top.

Here is the example from the help:

library(dendextend)

## Create complex dend:
dend <- iris[1:30,-5] %>%
  dist %>%
  hclust %>%
  as.dendrogram %>% 
  set("branches_k_color", k=3)
## Transfer to ggplot2
ggd1 <- as.ggdend(dend)

library(ggplot2)
## Create a radial plot:
ggplot(ggd1) + scale_y_reverse(expand = c(0.2, 0)) + coord_polar(theta="x")

Look carefully at the '12 o clock' position.

My setup: R 3.5.1 dendextend 1.8.0 ggplot2 2.2.1.9000