I have an arcplot with node order manually specified. I had hoped to set arc color by manually specifying with a list as well. However, the colors don't line up to the nodes:
Where red, blue, and green were previously defined as:
red <- "firebrick1"
green <- "green3"
blue <- "DodgerBlue"
color.names <- setNames(c(red, red, red, red, red,red,red,red,red,red,red,red, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue,green, green , green, green ), c("OVB", "OVB-ENV", "OVB-ENV-MO", "OVB-MO", "OVB-MO-ENV", "ENV-MO", "ENV", "ENV-OVB", "ENV-MO-OVB", "MO","MO-ENV","MO-OVB", "intraverbal-tact", "intraverbal", "intraverbal-mand", "intraverbal-tact-mand","intraverbal-mand-tact", "intraverbal-echoic-mand", "intraverbal-echoic", "tact", "tact-mand", "tact-intraverbal", "tact-intraverbal-mand", "mand", "mand-tact", "mand-intraverbal", "mand-tact-intraverbal","echoic-tact", "echoic-intraverbal-mand", "echoic-intraverbal", "echoic-tact-mand","echoic-intraverbal-tact", "echoic-mand","echoic-mand-intraverbal", "echoic-tact-intraverbal","social", "social-physical", "physical-social", "physical"))
longer_order = c("OVB", "OVB-ENV", "OVB-ENV-MO", "OVB-MO", "OVB-MO-ENV", "ENV-MO", "ENV", "ENV-OVB", "ENV-MO-OVB", "MO","MO-ENV","MO-OVB", "intraverbal-tact", "intraverbal", "intraverbal-mand", "intraverbal-tact-mand","intraverbal-mand-tact", "intraverbal-echoic-mand", "intraverbal-echoic", "tact", "tact-mand", "tact-intraverbal", "tact-intraverbal-mand", "mand", "mand-tact", "mand-intraverbal", "mand-tact-intraverbal","echoic-tact", "echoic-intraverbal-mand", "echoic-intraverbal", "echoic-tact-mand","echoic-intraverbal-tact", "echoic-mand","echoic-mand-intraverbal", "echoic-tact-intraverbal","social", "social-physical", "physical-social", "physical"))
There are 738 edges.
To graph the plot:
library(arcdiagram)
arcplot(F1, ordering=longer_order, col.arcs = color.names)
Is there something akin to igraph's get.edglist() for arcplot's (unique) list of nodes to graph (from an edge-list)? Some other way to programmatically add the colors of the edges by origin?
To reproduce the data:
F1 <- structure(c("OVB", "OVB", "OVB", "OVB", "OVB-ENV", "OVB", "OVB","intraverbal-mand", "intraverbal-mand", "mand", "intraverbal","mand", "intraverbal-tact", "intraverbal", "mand-intraverbal","intraverbal-mand", "mand", "physical-social", "physical-social","social-physical"), .Dim = c(10L, 2L), .Dimnames = list(NULL,c("V1", "V2")))
Something like this:
longer_order_match <- order(match(unique(matrix(F1)), longer_order))
color.names_match <- color.names[match(unique(matrix(F1)), longer_order)]
arcplot(F1, ordering = longer_order_match, col.arcs = color.names_match)
We need to provide same number of elements as number of edges to ordering =
and col.arcs =
arguments. So we are subsetting your predefined orders and columns vectors using match()
.