Hi guys!
platform: Windows
R version: 3.6.3
igraph version : 1.2.5
I am trying to use more vertex.shape to visualize my network so I follow some code to add two custom shapes triangle and rhombus.
But I found I can not control the vertex.frame.color
to the custom shape
A simple example
library(igraph)
g <- make_ring(10)
myrhombus <- 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]
}
symbols(x = coords[, 1], y = coords[, 2], bg = vertex.color,
stars = cbind(1.2*vertex.size, vertex.size, 1.2*vertex.size, vertex.size),
add = TRUE, inches = FALSE)
}
add_shape("rhombus", clip = shapes("circle")$clip,plot = myrhombus)
mytriangle <- 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]
}
symbols(
x = coords[, 1], y = coords[, 2], bg = vertex.color,
stars = cbind(vertex.size, vertex.size, vertex.size),
add = TRUE, inches = FALSE)
}
add.vertex.shape("triangle", clip = shapes("circle")$clip,plot = mytriangle)
V(g)$shape <- c(rep("circle",3),rep("square",3),rep("triangle",2),rep("rhombus",2))
plot(g,vertex.frame.color=NA)
Also can somebody show my how to add a diamond shape and an up-triangle shape?
Thanks