Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertex labels: positions depend on length #63

Closed
satuhelske opened this issue Feb 23, 2015 · 2 comments
Closed

Vertex labels: positions depend on length #63

satuhelske opened this issue Feb 23, 2015 · 2 comments

Comments

@satuhelske
Copy link

Could you add an argument to plot.igraph such that the user could decide to align the vertex labels and/or fix the distances from the labels to the corresponding vertices in vertical or horizontal direction? At the moment the vertex label positions vary according to the length of the label, but if the vertices are aligned, it would be nice to have the labels aligned as well. Thank you for a great package!

@satuhelske
Copy link
Author

I'm again inquiring about the possibility to change label positions. For personal use the problem is of course easy to solve by modifying the plot.igraph function (by deleting log10(nchar(labels) + 1)). However, I use the igraph package for drawing graphs in my own package which I would like to add to CRAN. It would be much easier to be able to use the original igraph functions instead of using my own copy of the plot.igraph function and all internal functions used by it – I've understood that using the ::: operator is not allowed in packages available in CRAN.

Below is an example of the problem. In the first graph the vertex labels are of the same length and align nicely.

adjm <- matrix(c(0,1,0,1,
                 0,0,1,1,
                 0,0,0,1,
                 0,0,0,0), nrow=4, byrow=TRUE)

g1 <- graph.adjacency(adjm, mode="directed")

values <- lapply(1:4, function(x) sample(1:4,4))

plot(g1, layout=layout.grid(g1, width=4), 
     vertex.shape="pie", vertex.pie=values,
     vertex.pie.color=list(heat.colors(4)),
     edge.curved=TRUE,
     vertex.label=LETTERS[1:4], vertex.size=50,
     vertex.label.dist=5, vertex.label.degree=pi/2, 
     edge.label=1:5, rescale=FALSE, 
     xlim=c(-0.2,3.5), ylim=c(0,0.5))

image

In the second graph the labels are of different lengths. The requested distance is the same for all vertex labels, but the true distances vary, which does not look good.

plot(g1, layout=layout.grid(g1, width=4), 
     vertex.shape="pie", vertex.pie=values,
     vertex.pie.color=list(heat.colors(4)),
     edge.curved=TRUE,
     vertex.label=c("A", "AA", "AAAA", "AAAAAA"), vertex.size=50,
     vertex.label.dist=5, vertex.label.degree=pi/2, 
     edge.label=1:5, rescale=FALSE, 
     xlim=c(-0.2,3.5), ylim=c(0,0.5))

image

Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant