I am creating a dendrogram in R from the hclust
function, I then used ape
package to create and unrooted phylogeny (purely for visualisation) and plot it using basic R plot
. This looks exactly how I want except I have 166 observations in 4 classes. This means the labels overlay and it looks like a jumbled mess.
My question is how can I (if at all) jitter the labels so that they overlay as little as possible? I have messed around with different cex
settings however they grouping stays tight no matter what value I pick.
library(RColorBrewer)
library("dendextend")
library("dendextendRcpp")
library(cluster)
library(ape)
# Try ward distance clustering
clust.compl = hclust(dist,method = 'ward.D2')
dend = as.dendrogram(clust.compl)
# Color branches - using dendoextend and dendoextendRcpp
colors <- brewer.pal(4, "Dark2")
# Cut tree so as to color based on cluster
clus4 = cutree(clust.compl, h=heights_per_k.dendrogram(dend)["4"])
# Plot unrooted
plot(as.phylo(clust.compl),
type = "unrooted",
edge.width = 2, edge.lty = 2,
tip.color = colors[clus4],
no.margin = TRUE,
label.offset = 0.5
)
Any help appreciated