igraph - igraph 使用的调色板是什么?

标签 igraph

我的可重现示例如下:

get.vertex.attribute(g)
$name
 [1] "LV" "Ve" "Ca" "Ai" "BN" "EN" "Or" "So" "SG" "Bo" "AX" "Sa" "To" "Pe" "Da" "He" "VI" "Ke" "Va" "At" "Ac" "Mi"
[23] "Cr" "Le" "Pu" "Re" "Te" "C." "N." "Y." "M." "D." "F." "L." "P." "S." "B." "J." "I." "A." "H." "R." "E." "O."

$color
 [1] 1 1 1 1 1 2 3 1 1 3 1 3 3 3 1 4 3 5 3 1 1 6 2 6 1 3 3 1 1 1 1 3 1 2 3 1 5 1 2 3 3 4 3 6

就我而言,以下代码:

library("igraph")
vertices<-data.frame("name" = unique(unlist(relations)))
g = graph.data.frame(relations, directed=F, vertices=vertices)
vertices$group = edge.betweenness.community(g)$membership 
V(g)$color <- vertices$group
plot(g,layout=layout.auto,vertex.size=6,  vertex.label.cex = 0.8)

给出了这个图: enter image description here 其中颜色 1 似乎是橙色,2 是浅蓝色,等等...... 还没有

palette()
[1] "black"   "red"     "green3"  "blue"    "cyan"    "magenta" "yellow"  "gray"   
>

那么 igraph 使用的调色板是什么? 我很好奇,因为我想在另一个包中使用它,该包仅将颜色名称作为输入,并且似乎无法将 V(g)$color 向量识别为输入候选(即仅输出黑色)。

最佳答案

简短的答案是categorical_pal(8)

完整故事

如果您查看帮助页面?igraph.plotting并搜索palette,您会发现。

palette

The color palette to use for vertex color. The default is categorical_pal, which is a color-blind friendly categorical palette. See its manual page for details and other palettes.

帮助页面?categorical_pal说:

This is a color blind friendly palette from http://jfly.iam.u-tokyo.ac.jp/color. It has 8 colors.

我们可以对此进行快速演示。

library(igraph)
x = 1:8
y = rep(1,8)
plot(x,y, pch=20, cex=10, col=categorical_pal(8), xlim=c(0.5,8.5))

enter image description here

关于igraph - igraph 使用的调色板是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51483805/

相关文章:

r - 提取有关 tidygraph 中特定节点的邻域/子图

r - 在 igraph R 中查找没有任何前趋/传入边的顶点

r - 删除igraph R中顶点之间的边

r - 如何将 R "network"对象转换为 "igraph"对象?

python - 如何在 python 中制作力导向图?

r - for循环删除igraph中的顶点属性

r - 获取图 igraph 中父节点的度数

R中igraph中的R倒数边

r - 查找 DAG 中节点值的累积和

r - 通过原点节点指定圆弧颜色 arcplot {arcdiagram}