library(stats)
d <- matrix(0,5,5)
d[lower.tri(d)] <- c(9,3,6,11,7,5,10,9,2,8)
d <- d t(d)
d <- as.dist(d)
hc.s <- hclust(d, "single")
plot(hc.s,hang=-1)
This graph is okay, but the axis is ugly. In my textbook, the figure is as below: How to make my graph in the same way as the textbook?
CodePudding user response:
You can add your own axes
par( mar=c(5,5,8,16) )
plot( hc.s,hang=-1, axes=F, labels=F )
axis( 1, 1:length(hc.s$order), labels=hc.s$order, col=NA, pos=0.2 )
axis( 2, 0:max(hc.s$height), las=1 )
points( 1:5, rep(0,5), pch=19 )
CodePudding user response:
try using factoextra
library(factoextra)
fviz_dend(hc.s)