Rotating labels for networx object in R

19 views Asked by At

I have a dtm matrix, and I want to plot it using NeigborNet algorithm. Here is my code:

library(stylo)
library(phangorn)
data("galbraith")
dist.mx <- as.matrix(dist.wurzburg(galbraith))
nnet <- phangorn::neighborNet(dist.mx)                     
par(mar = c(0,0,0,0))
plot(nnet,
     type = "equal angle", 
     tip.offset = 0.9,
     edge.color = "grey20",
     edge.width = 1,
     font = 1,
     cex = 0.7,
     use.edge.length = F, 
)

As one can see here, some labels overlap, because they are all horizontal. Is there a way to rotate them? (ideally at the angle of the nearest edge)

enter image description here

1

There are 1 answers

0
LocusClassicus On

The issue was resolved by the developer of the package: https://github.com/KlausVigo/phangorn/issues/162

Additional argument direction="axial" does the trick.