Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't read the labels on a hierarchical clustering plot

Tags:

plot

r

I am in 2 weeks into programming into R, and I am doing hierarchical clustering (using agnes) on a set of 150 documents. When I do the clustering, the plot looks really bad as all of the labels overlap, it basically looks like a mess. What is the best way to

  • create a larger plot that I can zoom in if need be to read labels
  • creating smaller font, that is also readable

Here's the code I'm using

 cluster<- agnes(sim_matrix,diss="TRUE",method="ward")
 dimnames(sim_matrix) = list(docnames, docnames)
 plot(cluster)
like image 889
user2680293 Avatar asked Dec 02 '25 12:12

user2680293


1 Answers

Save the output to a file:

pdf(file="dendrogram.pdf", height=10, width=30)
plot(cluster, which.plots=2, cex=1)
dev.off()

Change the height and width of the pdf until the labels and the dendrogram are visible. You can also adjust font size via cex argument.

If you prefer the PNG or other file formats, check ?png

like image 157
TWL Avatar answered Dec 05 '25 02:12

TWL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!