单个顶点标签文本的igraph多色 [英] igraph multicolor for a single vertex label text

查看:75
本文介绍了单个顶点标签文本的igraph多色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能要问的太多了,但是是否可以仅对标签文本的一部分进行着色?例如,我有一个带有2行标签的顶点,我希望第一行使用黑色字体,第二行使用红色字体.有什么可以做的吗?

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?

非常感谢!!

推荐答案

您可以手动放置标签(如果没有其他方法).

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

这篇关于单个顶点标签文本的igraph多色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆