Multiple Color Values For A Single Node In Igraph
2
0
Entering edit mode
11.8 years ago
raunakms ★ 1.1k

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 • 7.8k views
ADD COMMENT
3
Entering edit mode
11.8 years ago
Gabor ▴ 70

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.

ADD COMMENT
0
Entering edit mode

Great Thanks .....

ADD REPLY
0
Entering edit mode

How would one add a legend for this?

ADD REPLY
1
Entering edit mode
11.8 years ago
Sudeep ★ 1.7k

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"

ADD COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1324 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6