1
votes

I have a network with some directed and some undirected edges. I'm trying to use igraph to plot it using the arrow.mode parameter, but the graph is always showing arrows with default parameters. Here's an example

Here are some data:

spearRhoP_lagged4 <- structure(list(Var1 = c("ARISA_538.9", "ARISA_538.9", "ARISA_666.4", 
"ARISA_686.9", "ARISA_538.9", "ARISA_594.1"), Var2 = c("ARISA_666.4", 
"ARISA_686.9", "ARISA_686.9", "ARISA_666.4", "ARISA_561.8", "ARISA_561.8"
), rho = c(0.280885191364122, 0.415365287156247, 0.614493076574831, 
0.312630564055403, 0.295296877306726, 0.381890811408216), p = c(0.00206314544835896, 
2.9098006351119e-06, 1.35005674822095e-13, 0.000567475872663549, 
0.00116911931220592, 1.98010880043619e-05), delay = c(0, 0, 0, 
1, 0, 0), fdr = c(0.0135393920048557, 7.97032347878478e-05, 2.83511917126399e-11, 
0.00503534929264839, 0.00898225813036257, 0.000366902513022), 
    arrow = c("-", "-", "-", ">", "-", "-")), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L), groups = structure(list(
    Var1 = c("ARISA_538.9", "ARISA_538.9", "ARISA_538.9", "ARISA_594.1", 
    "ARISA_666.4", "ARISA_686.9"), Var2 = c("ARISA_561.8", "ARISA_666.4", 
    "ARISA_686.9", "ARISA_561.8", "ARISA_686.9", "ARISA_666.4"
    ), .rows = list(5L, 1L, 2L, 6L, 3L, 4L)), row.names = c(NA, 
-6L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE))

Then I build the graph

LaggedSpearGraph <- graph_from_data_frame(spearRhoP_lagged4)

Lastly I plot the graph, telling it that I want the arrow direction to be specified by the parameter arrow

plot(LaggedSpearGraph,
      vertex.size=2,
      arrow.mode = E(LaggedSpearGraph)$arrow)

I get an output that looks like this.

GraphWithTooManyArrows

But what I want is a network where there is only one edge with an arrow on it.

Any suggestions?

1

1 Answers

1
votes

You need to add edge as a prefix:

LaggedSpearGraph <- graph_from_data_frame(spearRhoP_lagged4, directed=T)

plot(LaggedSpearGraph,
     vertex.size=10,
     edge.arrow.mode = E(LaggedSpearGraph)$arrow)

enter image description here

See here: https://github.com/igraph/igraph/issues/954