AnCo
AnCo

Reputation: 51

How to colour edges in a multiplex network with R

I am currently analysing a multiplex network based on a dataset created by myself.

I want to be able to plot the network in a way that I can assign different colours to the two types of edges in by multiplex network.

The edgelist of this network looks like this edgelist

I tried to plot it with the following code:

plot(multi_g, 
     edge.color=c("brown", "green")[E(multi_g)$trade_tie+E(multi_g)$bilateralaid_tie],
     edge.arrow.size = 0.5,
     vertex.color="gray40", 
     vertex.label.color = "black",
     layout= layout_with_fr)

By using this formula many edges are not plotted.

Thank you in advance for your help.

If there is a way to plot it with ggraph I would also really appreciate it!

Upvotes: 3

Views: 253

Answers (1)

AnCo
AnCo

Reputation: 51

Thanks Paul! I was able to plot it like this using both the curving as you suggested and the ifelse () function to tell R when to colour which edge.

plot(multi_g, 
     edge.color=ifelse(E(multi_g)$trade_tie>0,"burlywood4","darkgreen"),
     edge.arrow.size = 0.1,
     edge.curved=0.3,
     vertex.color=c('green','brown')[(V(trade_g)$`Export/Import`=="export")+1], 
     vertex.label.color = "black",
     layout= layout_with_kk)

Upvotes: 1

Related Questions