hello , i have problome with my social network , idid get the network but icannot add legends to it please help
heres the instruction :
Each quake is characterized by a couple of integers which determine its position in space (latitude and longitude). Create an empty social network in which each quake is represented by a node (empty_graph() %>% plot.igraph()): • Node size depends on quake intensity (vertex.size = …) • Node color depends on quake depth (vertex.color = …) • Node position depends on latitude and longitude columns (layout = …) Adjust the different parameters to make your map readable (node size, color and latitude/longitude). Add a title and a legend explaining nodes’ color (legend())
my codes :
attach(quakes)
library(igraph)
eg=make_empty_graph(n=1000,directed = F)
plot.igraph(eg,layout=as.matrix(select(quakes,lat,long)),vertex.color=quakes$depth,vertex.size=quakes$mag*5, main="network of quakes")
legend("bottomleft", legend=levels(as.factor(V(eg) , col = coul , bty = "n", pch=20 , pt.cex = 3, cex = 1.5, text.col=coul , horiz = FALSE, inset = c(0.1, 0.1))
what am i doing wrong? without the legends i get the network but with it igot an error