igraph / rigraph

igraph R package
https://r.igraph.org
541 stars 200 forks source link

Feature request: rotatable vertex labels #106

Open BrianDiggs opened 9 years ago

BrianDiggs commented 9 years ago

I would like to request a new feature: the ability to rotate (set the text angle of) the vertex labels that are printed. My motivation for this was creating a graph with the sugiyama layout. I have long names for my vertices, and with them arranged along horizontal lines, the labels were overlapping to the point of being unreadable.

As a brute force proof-of-concept, I edited a local copy of plot.igraph and added a srt argument to text at https://github.com/igraph/rigraph/blob/dev/R/plot.R#L394. All the labels were printed at my (fixed, constant) specified angle. A proper implementation would allow the angle to be set as a vertex parameter (vertex.label.angle, perhaps? A consideration as to if it should be in degrees (as srt expects) or radians (to be consistent with vertex.label.degree) is needed). There are other text calls in the "add the labels" section of plot.igraph that would need to be changed, and I did not even look at whether this was possible with tkplot or rglplot

In addition to helping with long labels with the sugiyama layout, I imagine it could be helpful for grid layouts too.

HedvigS commented 6 years ago

I would also really appreciate this. I've spent the past 20 minutes non-stop trying to google a solution and not really getting anywhere.