2

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"))) 
zx8754
  • 52,746
  • 12
  • 114
  • 209
d-cubed
  • 1,034
  • 5
  • 30
  • 58
  • Are colours not supposed to be in quotes: `setNames(c("red", "red", ...` instead of `setNames(c(red, red` ? Also `col.names` is supposed to be `color.names`? – zx8754 Jun 04 '16 at 20:05
  • 1
    Personal opinion, I stopped using arcplots because of sankey from googleVis package, see if it works for you. – zx8754 Jun 04 '16 at 20:14
  • 1. as mentioned above, the color variables red, etc. had been previously defined, i.e., red not "red" 2. Sankey diagrams with googleVis look awesome. I'll need to give them a try. – d-cubed Jun 04 '16 at 21:15
  • 1
    They've been added above – d-cubed Jun 04 '16 at 21:31

1 Answers1

3

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().

enter image description here

zx8754
  • 52,746
  • 12
  • 114
  • 209