rigraphtkplot

Change edge thickness with tkplot (Igraph, R)


I was wondering if there is a way to change the edge thickness when using tkplot()

I know you can do it by right clicking the edge and changing it manually, but I would like to be able to call up an attribute to use for the edge. Similar to when using the normal plot function in igraph where I can do edge.width=E(g)$Weight

Also, is there a way to save the tkplot as a png without the use of other packages? Thanks!


Solution

  • Yes, you can change the edge width, actually it works exactly the same way as for plot().

    The Tk canvas does not support the PNG format, so you cannot save tkplot() output in PNG. If you use tkplot() for adjusting coordinates, then use tkplot.getcoords() to query the adjusted coordinates and then use plot() with these coordinates to create the PNG file.

    library(igraph)
    g <- graph.ring(10)
    id <- tkplot(g, edge.width=1:10)
    ## Now adjust the coordinates by hand, and then continue.
    ## E.g. I moved vertex 7 to the middle
    co <- tkplot.getcoords(id)
    png("output.png")
    plot(g, layout=co, edge.width=1:10)
    dev.off()
    

    example output figure