0

I am trying to produce a black-and-white network diagram using node symbols (point shapes) to differentiate node types, instead of using colors. However, I cannot find a way to do this using the gplot function in the package sna. Here's a simple example:

library(network)
library(sna)
set seed(100)
net <- as.network(matrix(sample(c(0:1),100,replace=TRUE),nrow=10,ncol=10))
symbols <- rep(c(1:2),5)
gplot(net,pch=symbols) 

At least with my version of r and sna, gplot just ignores pch. I found documentation here which seems to indicate that at one point vertex.pch could be used to set node symbols. However, this is no longer in the sna documentation and the following code results in an error:

gplot(net,vertex.pch=symbols)

Is there a way to substitute symbols for colors in a network plot, ideally using gplot (I am trying to produce some black and white versions of existing color plots, so I'd rather not start from scratch if possible)?

tvg
  • 388
  • 2
  • 13

1 Answers1

1

gplot doesn't directly support pch, but it does let you change the number of sides in the vertex polygon using the vertex.sides argument. So if you wanted to draw your example with triangles and squares:

gplot(net,vertex.col='black',vertex.sides = symbols+2)
skyebend
  • 1,079
  • 6
  • 19
  • I did try this but I could never get it to look esthetically pleasing; sometimes the polygons seem somewhat rotated so they don't look like 'clean' squares, triangles, etc. I may switch to the plot function in igraph. – tvg Jul 15 '15 at 11:39
  • you can use the `vertex.rot` parameter to rotate the poloygons in degrees. But I believe igraph allows arbitrary symbols, which may be more what you want. – skyebend Jul 15 '15 at 15:42