***** To join INSNA, visit http://www.insna.org *****
Hi Ian,
I can show you code for igraph -- would need to think about it a bit more in statnet, but the principles are the same. Not elegant, no doubt, but it works. There may, for example, be a simpler way to do this with a merge of some sort. I just did this on a graph I had handy. I colored the names according to communities (found using the spinglass.community algorithm) using the colorspace package.
Given a graph g (370 vertices, 1565 edges):
spc <- spinglass.community(g, spins=20)
cols <- rainbow_hcl(10, c = c(80, 30), l = c(30, 90)) ## colorspace
g.layout <- layout.fruchterman.reingold(g)
ccc <- sort(betweenness(g), decreasing = TRUE)
thebigs <- names(ccc[1:20])
bignames <- rep(NA,370)
aaa <- rep(NA, 20)
for(i in 1:20) aaa[i] <- which(thebigs[i] == V(g)$name)
bignames[aaa] <- thebigs
V(g)$bignames <- bignames
plot(g, vertex.label=V(g)$bignames, layout=g.layout,
vertex.size=0, vertex.color="white", vertex.frame.color="white",
vertex.label.cex=0.75, vertex.label.color=cols[spc$membership], edge.color=rgb(209,209,209,70, max=255), edge.width=2)
You can alter the vertex label size, for example passing a vector argument to the vertex.label.cex argument.
Hope this helps.
Cheers,
Jamie
--
James Holland Jones
Associate Professor of Anthropology &
Senior Fellow, Woods Institute for the Environment
450 Serra Mall
Building 50
Stanford, CA 94305-2034
phone: 650-721-2484
fax: 650-725-0605
email: [log in to unmask]
url: http://www.stanford.edu/~jhj1
> On Aug 23, 2015, at 4:33 PM, Ian McCulloh <[log in to unmask]> wrote:
>
> ***** To join INSNA, visit http://www.insna.org *****
> Hello!
>
> I'm doing an SNA project on an organization of about 120 nodes. I am using Statnet in R. I want to make an SNA visualization where I only visualize the labels for the most central 10 or 20 nodes. Does anyone have some R code that does this?
>
> For context and example, here is code I have that will allow me to scale the node label based on centrality, and I can color the edges gray for contrast.
>
> gplot(gn, label.cex=node.scale(node.scale(betweenness(gn))), label.col=1, label=network.vertex.names(gn), vertex.col=2, edge.col=8, vertex.cex=0.5)
>
> I'd also be interested in iGraph implementation, but I'm using statnet for this project.
>
> Kind Regards,
>
> Ian
>
>
> _____________________________________________________________________ SOCNET is a service of INSNA, the professional association for social network researchers (http://www.insna.org). To unsubscribe, send an email message to [log in to unmask] containing the line UNSUBSCRIBE SOCNET in the body of the message.
_____________________________________________________________________
SOCNET is a service of INSNA, the professional association for social
network researchers (http://www.insna.org). To unsubscribe, send
an email message to [log in to unmask] containing the line
UNSUBSCRIBE SOCNET in the body of the message.
|