This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Multiple Color Values For A Single Node In Igraph

I'm using a R package "igraph" for a network visualization. In the network diagram from igraph I've only seen that a particular node represented by a single color. I want to give multiple color labels to a single node (some what like a piechart) to represent different characteristics of that node. The node could be something like the picture below. Can anyone suggest me any idea how I can achieve this using igraph or using any other packages.

enter image description here

graph r

2 answers

Here is how to do it in igraph, it is actually pretty simple:

g <- graph.ring(10)
values <- lapply(1:10, function(x) sample(1:10,3))
plot(g, vertex.shape="pie", vertex.pie=values,
     vertex.pie.color=list(heat.colors(5)),
     vertex.size=seq(10,30,length=10), vertex.label=NA)

The example is quite self-explanatory I think, but you can also look at the ?vertex.shape.pie manual page.

Great Thanks .....

How would one add a legend for this?

If you insist on using an R package try Rgraphviz and the tutorial How To Plot A Graph Using Rgraphviz section 6 "Customized node plots"

Thanks Sudeep. I think that Rgraphviz should solve the problem.

Log in to answer this question.