Reputation: 11
I have a fruchterman reingold plot of 20 random students' extra curricular activities with the vertex color based on their final grades (numeric, ranging from 0-20) in an associated data set. Is there a way to to display a legend that prints the range for each vertex color?
library(igraph)
a <- graph.adjacency(sport,mode="undirected")
plot(a,layout=layout.fruchterman.reingold, vertex.size=6, vertex.color=portsmall$G3)
Here is a impage of my plot with colored vertices:
https://i.sstatic.net/0vc3j.png
Upvotes: 1
Views: 1825
Reputation: 94202
You can just use the legend
function. For example:
legend("top",legend=c(1,2,3),fill=c("red","green","blue"))
You'll need to work out the precise nature of the parameters since we don't have your data so we can't guess. Read the docs for legend
for more.
Upvotes: 1