Search code examples
rlatexdendrogramhclust

How to label nodes of a dendrogram with mathematical symbols?


I am doing cluster analysis on some set of mathematical objects. The basic R has the functionality to plot mathematical symbols. I want to label nodes of my dendrogram with some mathematical symbols. How to incorporate this in plot function for hclust object? For instance, I want to label my nodes with letters with subscript, e.g.,

T2

How to do this in R?


Solution

  • Try this:

    library(latex2exp)
    library(dendextend)
    tree <- hclust(d = dist(x = iris[1:20, 1:4])
    dend <- as.dendrogram(tree)
    labels(dend) <- TeX("$\\pi_2^3 (\\xi_3^4)$")
    plot(dend)
    

    enter image description here