1

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?

Samuel
  • 2,895
  • 4
  • 30
  • 45
Piotr Wilczek
  • 187
  • 1
  • 1
  • 10

1 Answers1

2

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

Samuel
  • 2,895
  • 4
  • 30
  • 45
  • This works well for my data. How to incorporate Greek letters in dendrogram? I am not fluent with latex2exp package. – Piotr Wilczek Nov 15 '18 at 00:18
  • To mark an answer as accepted, click on the check mark beside the answer to toggle it from grayed out to filled in. – Samuel Nov 15 '18 at 00:24
  • If I do not disturb you, how to incorporate parentheses an/or symbols with (simultaneously) subscripts and superscripts in dendrograms ? – Piotr Wilczek Nov 15 '18 at 00:25
  • I have updated my answer according to your comment. Where would you like the parenthesis to be? – Samuel Nov 15 '18 at 00:27