Search code examples
rdendrogram

How to rotate the plot in r base package graphics?


I know this is a little bit too much, but I am plotting a dendrogram plot in r, and here is my code:

dd <- dist(scale(full[,c(1,2,3,4)]),method="euclidean")
hc = hclust(dd,method="ward.D2")
dend <- color_branches(as.dendrogram(hc),6)

labels_colors(dend) <-
  rainbow_hcl(6)[sort_levels_values(
    as.numeric(classified[, 9])[order.dendrogram(dend)]
  )]
plot(dend,horiz=T)

and I got this plot: enter image description here Is there any way can do mirror symmetry to make it like this:(please ignore the difference in colour) enter image description here


Solution

  • plot_horiz.dendrogram(dend, side = TRUE)
    

    should do the trick. See https://rdrr.io/cran/dendextend/f/vignettes/FAQ.Rmd