Michael Gruenstaeudl
2018-02-12 12:59:20 UTC
Dear igraph users,
I am using the igraph to visualize the association between the two
variables (s and g).
In shell:
$ cat file
s g
s1 foo bar
s2 foo bar baz qux
s99 foo
s9999 foo bar baz qux
s99999 foo
s999999 foo
In R:
m <- as.matrix(read.table(file="~/path_to_file/file", sep="\t", header=T))
g <- graph_from_edgelist(m)
V(g)$type <- bipartite.mapping(g)$type
coords <- layout_as_bipartite(g)
plot.igraph(g, layout = -coords[,2:1],
vertex.shape="rectangle",
vertex.size=10,
vertex.size2=1,
vertex.color=NA,
vertex.frame.color=NA,
vertex.label.color="black",
vertex.label.family="sans",
edge.label.color="white",
edge.arrow.mode=0,
edge.width=3,
asp=5)
However, the resulting visualization has the vertex labels and the edges
overlap, making the labels difficult to read. For an example, see:
Loading Image...
I would like to adjust the R code such that all vertex labels are moved
away from the vertex center (i.e., vertex labels of s moved to left,
vertex labels of g moved to right) and that all vertex labels are
left-aligned (and not centered, as is the default case).
Can I do that via igraph and if so, how?
Best, Michael Gruenstaeudl
Michael Grünstäudl (Gruenstaeudl), PhD
Freie Universität Berlin
I am using the igraph to visualize the association between the two
variables (s and g).
In shell:
$ cat file
s g
s1 foo bar
s2 foo bar baz qux
s99 foo
s9999 foo bar baz qux
s99999 foo
s999999 foo
In R:
m <- as.matrix(read.table(file="~/path_to_file/file", sep="\t", header=T))
g <- graph_from_edgelist(m)
V(g)$type <- bipartite.mapping(g)$type
coords <- layout_as_bipartite(g)
plot.igraph(g, layout = -coords[,2:1],
vertex.shape="rectangle",
vertex.size=10,
vertex.size2=1,
vertex.color=NA,
vertex.frame.color=NA,
vertex.label.color="black",
vertex.label.family="sans",
edge.label.color="white",
edge.arrow.mode=0,
edge.width=3,
asp=5)
However, the resulting visualization has the vertex labels and the edges
overlap, making the labels difficult to read. For an example, see:
Loading Image...
I would like to adjust the R code such that all vertex labels are moved
away from the vertex center (i.e., vertex labels of s moved to left,
vertex labels of g moved to right) and that all vertex labels are
left-aligned (and not centered, as is the default case).
Can I do that via igraph and if so, how?
Best, Michael Gruenstaeudl
Michael Grünstäudl (Gruenstaeudl), PhD
Freie Universität Berlin