igraph multicolor for a single vertex label text

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:08:32

问题


This might be too much to ask, but is it possible to color only part of the label text? For example, I have a vertex with 2-line label, and I want the first line in black font and the second line in red font. Anything can be done?

Many thanks!!


回答1:


You can put the labels manually (if there is no other way).

library(igraph)
g1 <- graph.atlas(sample(0:1252, 1))

layout1 <- layout.fruchterman.reingold(g1)
plot(g1, layout = layout1)

layout2 <- apply(layout1, 2, function(x) {
  x <- x / (max(x)-min(x))*2
  x <- x - min(x) - 1
})

text(layout2[,1], layout2[,2], pos = 3, labels = letters[1:length(V(g1))], col ="red" )



来源:https://stackoverflow.com/questions/29148318/igraph-multicolor-for-a-single-vertex-label-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!