rigraphtkplot

Feed coordinates to tkplot() or use tkplot's arrows in plot.igraph()


Is there a way I can feed a matrix of coordinates to the tkplot function in igraph? I've tried setting the layout argument to my matrix of coordinates but it just produces a blank plot.

I'm able to feed coordinates to plot.igraph() and produce a directed, weighted edge plot with the vertices in the places that I want them. BUT, the arrows are funky. The arrows are placed underneath the edges so that if the edge is wide enough (some of mine are), then the arrow is at least partially hidden. I've tried changing edge and arrow width but some of my edges are just weighted too much. The arrows produced in tkplot are closer to what I want.

The first plot below corresponds to the undesired arrows made with plot.igraph. Second plot is for the desired arrows from tkplot.

Arrows I don't want:

badarrows

Arrows I do want:

goodarrows

The reason I need to do one or the other, is because I'll need to make a few more of these graphs with the nodes in the exact same location, and don't want to have to keep using tkplot to hand-move the nodes around every time. I have quite a bit of them and it will also be impossible to get them in exactly the same position as before.

Hopefully this is specific enough. This is my first time posting, so please let me know what other information I should include. I've tried giving tkplot coordinates on R 2.15 and on a machine running 2.11, as well as with igraph package 0.5.5 and igraph 0.6.5.

Truly sorry to waste time if this is out there somewhere. I've spent a while looking as well as trying to put heads together with my grad PI to figure it out and we've been hitting dead ends for a few days now. Thank you for any feedback.


Solution

  • Unfortunately it is not possible to modify how the arrows look, and I agree that this sucks, especially because they are ugly.

    To be a bit more constructive, you could use tkplot() to do the plots, you can actually automate saving them into files, with some tricks and using an internal igraph function. Here is an example below. Is this good enough?

    library(igraph)
    set.seed(1)
    g <- graph.star(10, center=10) %u% graph.ring(9, directed=TRUE)
    E(g)$width <- sample(1:10, ecount(g), replace=TRUE)
    lay <- layout.auto(g)
    
    id <- tkplot(g, layout=lay)
    tkp <- igraph:::.tkplot.get(id)
    tkpostscript(tkp$canvas, file="/tmp/output.eps")
    tkplot.close(id)
    

    plot