2

我有一个手动指定节点顺序的 arcplot。我曾希望通过手动指定列表来设置弧色。但是,颜色不符合节点:

其中红色、蓝色和绿色之前定义为:

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"))

有 738 条边。

要绘制图表:

library(arcdiagram)
arcplot(F1, ordering=longer_order, col.arcs = color.names)

是否有类似于 igraph 的 get.edglist() 用于 arcplot 的(唯一)要绘制的节点列表(来自边缘列表)?以编程方式按原点添加边缘颜色的其他方法?

要重现数据:

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"))) 
4

1 回答 1

3

像这样的东西:

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)

ordering =我们需要提供与边数和col.arcs =参数相同数量的元素。因此,我们使用 对您的预定义订单和列向量进行子集化match()

在此处输入图像描述

于 2016-06-04T21:46:16.303 回答