I have created a graph with the igraph-Package in R.
Now i want to make the graph more colorful. I want to color my network based on the type of "party" in my dataset. My dataset looks like this:
Screen.name mentions party
1 @A_Gloeckner @MartinSchulz SPD
2 @A_Gloeckner @MartinSchulz SPD
3 @A_Gloeckner @MartinSchulz SPD
4 @A_Gloeckner @ManuelaSchwesig SPD
5 @A_Gloeckner @sigmargabriel SPD
6 @A_Gloeckner @nahlesMeine SPD
... ... ... ...
33 @A_Schillhaneck @BA_Mitte_Berlin GRNE
34 @A_Schillhaneck @nytimes GRNE
35 @A_Schillhaneck @nutellaberliner GRNE
This is the code how i have created my graph:
gj <- graph.data.frame(joined_df, directed = TRUE)
plot(gj,
vertex.label = NA,
vertex.size = 2,
edge.arrow.size = 0.1,
vertex.label.cex = 0.8,
layout = layout.fruchterman.reingold)
The graph:
> gj
IGRAPH c5ba2ee DN-- 1279 2147 --
+ attr: name (v/c), color (v/c), party (e/c)
+ edges from c5ba2ee (vertex names):
[1] @A_Gloeckner->@MartinSchulz @A_Gloeckner->@MartinSchulz
@A_Gloeckner->@MartinSchulz
[4] @A_Gloeckner->@ManuelaSchwesig @A_Gloeckner->@sigmargabriel
@A_Gloeckner->@nahlesMeine
[7] @A_Gloeckner->@Willy @a_grotheer ->@NSC_CPMR @a_grotheer
->@SouthendRNLI
[10] @a_grotheer ->@weserkurier @a_grotheer ->@werderbremen
@a_grotheer ->@ribasdiego10
+ ... omitted several edges
Now i want the edges and vertices to be an own color for every different "party". In this case i just got two different parties ("SPD", "GRNE"). I want every node and vertice with the "party"-Value "SPD" to be red, and every value with "GRNE" to be green.
Does anybody know how to do this?
I know that i can change the colors with for example vertex.color = "red"
or edge.color = "red"
, but i don't know how to set the color on dependencies.
Thanks in advance for your help!