[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Color community results in one plot
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Color community results in one plot |
Date: |
Fri, 20 May 2016 15:15:09 +0200 |
Hi,
> I calculated communities on my graph with two different algorithms. To
> compare them visually I want to plot the graph with a specific layout, i.e.
> in my case fruchterman–reingold and color the vertices according to the
> first community structure.
> Then I want to change all colors to the second community structure, but
> preserve the position of all vertices.
> [...]
> Is one of these ideas doable with iGraph?
Yes - the plot() function has a layout=... argument that accepts an
arbitrary graph layout or the name of a layout algorithm. You can
simply create a layout first, store it in a variable, and then pass it
twice to plot():
my_layout = g.layout("fr")
cl1 = g.community_fastgreedy().as_clustering()
cl2 = g.community_walktrap().as_clustering()
plot(cl1, layout=my_layout)
plot(cl2, layout=my_layout)
T.