Network plot: Looking for a more detailed instruction in changing vertex.frame.width

189 views Asked by At

I have tried the solution provided in link, but the width of the vertex did not change after applying the code.

First, I defined the function myvertex using the code from the link.

  myvertex <- function(coords, v=NULL, params) {
  vertex.color <- params("vertex", "color")
  if (length(vertex.color) != 1 && !is.null(v)) {
    vertex.color <- vertex.color[v]
  }
  vertex.size  <- 1/200 * params("vertex", "size")
  if (length(vertex.size) != 1 && !is.null(v)) {
    vertex.size <- vertex.size[v]
  }
  vertex.frame.color <- params("vertex", "frame.color")
  if (length(vertex.frame.color) != 1 && !is.null(v)) {
   vertex.frame.color <- vertex.frame.color[v]
  }
  vertex.frame.width <- params("vertex", "frame.width")
  if (length(vertex.frame.width) != 1 && !is.null(v)) {
    vertex.frame.width <- vertex.frame.width[v]
  }

  mapply(coords[,1], coords[,2], vertex.color, vertex.frame.color,
     vertex.size, vertex.frame.width,
     FUN=function(x, y, bg, fg, size, lwd) {
       symbols(x=x, y=y, bg=bg, fg=fg, lwd=lwd,
               circles=size, add=TRUE, inches=FALSE)
     })
}

add.vertex.shape("fvertex", clip=igraph.shape.noclip,
             plot=myvertex, parameters=list(vertex.frame.color=1,
                                            vertex.frame.width=10))

Then, I plot the graph adding the new attribute vertex.frame.width.

plot(g,layout=layout.fruchterman.reingold, 
 vertex.color=V(g)$color,edge.width=EDGE$count,edge.lty=6,edge.arrow.size=0.3, 
 vertex.size=V(g)$size, vertex.label.color="grey", vertex.shape=V(g)$shape,
 vertex.frame.color=VERTEX$gender, vertex.frame.width=V(g)$width, 
 frame=F, main = "Network Plot of Teachers and Students", margin = 0.01)

It no longer returns the error message below but the width of the vertex frame remains the same even if I enter a larger value in the vertex.frame.width.

Error in i.parse.plot.params(graph, list(...)) : 
  Unknown vertex parameters: frame.width

This is what the plot looks like: network plot.

I am wondering if I am missing any steps in between. If anyone can provide a more detailed instruction, that would be great! Thank you in advance!

0

There are 0 answers