2014-12-04 75 views
1

我希望创建联网弧形图。我的问题是弧是正确的,节点的顺序也是如此。但是,节点(度)和填充以及边框颜色(vfill,vborder)的大小不匹配顶点的属性。R:顶点属性与弧形图中的顶点名称不匹配

我.gml文件可以在https://dl.dropboxusercontent.com/u/42761499/myarc.gml

代码下载:

library(igraph) 
library(arcdiagram) 
dat.g2 = read.graph("myarc.gml", format = "gml") 
vlabels<-get.vertex.attribute(dat.g2, "name") 
vfill<-get.vertex.attribute(dat.g2, "vfill") 
vborder<-get.vertex.attribute(dat.g2, "vborder") 
vgroups<-get.vertex.attribute(dat.g2, "group") 
degrees<-get.vertex.attribute(dat.g2,"degree") 
edgelist<-get.edgelist(dat.g2) 
values<-as.numeric(get.edge.attribute(dat.g2, "value")) 
par(mai=c(2.25,.25,.25,.25)) 
arc.p<-arcplot(edgelist, cex.labels = 0.8, 
      ordering = vlabels, 
      show.nodes = TRUE, 
      col.nodes = vborder, 
      bg.nodes = vfill, 
      cex.nodes = sqrt(degrees)/20, 
      pch.nodes = 21, 
      lwd.nodes = 2, 
      line = 0.3, 
      col.arcs = hsv(0, 0, 0.1, 0.4), 
      lwd.arcs = sqrt(values)/2, 
      horizontal=TRUE, 
      axes=FALSE) 

在情节的颜色和大小的节点,有时是错误的。 “其他投诉”应该是紫色的,CHPAIN黄色。至少CHPAIN和CARDOTH的大小是错误的(CHPAIN大于CARDOTH,请参阅myarc.gml)。我认为这个问题是因为在边缘列表中,每个节点的名称首先以与顶点顺序略有不同的顺序出现。 通过边缘列表顺序我的意思是当一个人看着整个行然后沿着列向下看时节点名称的唯一外观。 iethe前5行边缘列表的读取:

  • 从到
  • 1胸痛,MI,CA,VF AF
  • 2胸痛,MI,CA,VF晕厥
  • 3胸疼痛,MI,CA,VF SOB
  • 4胸痛,MI,CA,VF CHPAIN
  • 5胸痛,MI,CA,VF CARDOTH

所以电子dge列表顺序为“胸痛,MI,CA,VF”,“AF”,“晕厥”,“SOB”,“CHPAIN”,“CARDOTH”...顶点顺序为“胸痛,MI,CA,如何获得顶点属性(vfill,vborder,degrees)与顶点匹配图上的名字?

+0

的'arcdiagram'包是在这里:https://github.com/gastonstat/arcdiagram如果有人想知道.... – 2014-12-04 18:49:45

回答

2

您只需要明确设置vertices=参数。这是函数如何知道保留每个*.nodes属性分配给哪些值。您可以使用它来代替您现在设置的ordering=参数,因为您根本没有重新排序节点。

arc.p<-arcplot(edgelist, vlabels, cex.labels = 0.8, 
    show.nodes = TRUE, 
    col.nodes = vborder, 
    bg.nodes = vfill, 
    cex.nodes = sqrt(degrees)/20, 
    pch.nodes = 21, 
    lwd.nodes = 2, 
    line = 0.3, 
    col.arcs = hsv(0, 0, 0.1, 0.4), 
    lwd.arcs = sqrt(values)/2, 
    horizontal=TRUE, 
    axes=FALSE) 

enter image description here