【问题标题】:Plot Vertex shape in iGraph in R在R中的iGraph中绘制顶点形状
【发布时间】:2012-02-18 04:29:09
【问题描述】:

大家好,

我有一个应该很简单的问题。我是使用 iGraph 的新手,我正在尝试通过 tklplot 进行绘图。该图具有以下特点:

Vertices: 856 Edges: 675 Directed: TRUE

我只是想塑造不同的民族,当然是属性V(g)$ethnic的顶点,在图中。
我遇到了square 的问题,但它确实有一个错误。
在向下的线条中,我只是变成了圆形的顶点。我的想法是用属性V(g)$ethnic 区分顶点,如果我回忆一下,没有问题,但是绘图输出不正确,R没有报告大问题

如下

  V(g)$color <- "green"
  E(g)$color <- "black"
  V(g)$nodesize=degree(g)*0.5
  V(g)[V(g)$ethnic=="Mestizo"]$shape <- "rectangle"
  V(g)[V(g)$ethnic=="Saraguro"]$shape <- "circle"
  tkplot(g, layout=layout.kamada.kawai, edge.color=E(g)$color, 
         edge.arrow.size=0.3, vertex.label.dist=0.3, vertex.color=V(g)$color, 
         vertex.size=V(g)$nodesize, vertex.shape=V(g)$shape)

问候
弗拉基米尔

【问题讨论】:

    标签: r igraph


    【解决方案1】:

    根据igraph.vertex.shapes function documentationtkplot 不支持形状,而仅在plot.igraph 中支持:

    请注意,当前的顶点形状实现是实验性的,并且 将来可能会改变。目前已实现顶点​​形状 仅适用于 plot.igraph。

    【讨论】:

      【解决方案2】:

      究竟是什么没有正确绘制? iGraph 的索引偏移 1。试试这个,看看它是否有所作为:

      wc1 <- which(V(g)$ethnic=="Mestizo") - 1
      wc2 <- which(V(g)$ethnic=="Saraguro") - 1
      V(g)$shape[wc1] <- "rectangle"
      V(g)$shape[wc2] <- "circle"
      

      【讨论】:

      • 非常感谢您的回答,上述公式在tkplotplot.igraph 中均无效:报告了以下Warnmeldung:In graph[[9]][[3]][[name]][index + 1] &lt;- value : Anzahl der zu ersetzenden Elemente ist kein Vielfaches der Ersetzungslängeplot.igraph,@987654326 @ : 这意味着形状有问题或无法识别。
      猜你喜欢
      • 1970-01-01
      • 2020-07-15
      • 2015-07-21
      • 2020-01-27
      • 2013-01-21
      • 2017-10-19
      • 2012-10-19
      • 1970-01-01
      • 2013-04-06
      相关资源
      最近更新 更多