How to have a legend for colored edges in Julia plots?

156 Views Asked by At

Here is a minimal working code from Julia Discourse:

using LightGraphs
using GraphPlot
using Colors

g = graphfamous("karate")

membership = [1,1,1,1,1,1,1,1,2,1,1,1,1,1,2,2,1,1,2,1,2,1,2,1,1,1,1,2,1,1,2,1,1,1]
nodecolor = [colorant"lightgrey", colorant"orange"]
nodefillc = nodecolor[membership]

colors = [colorant"lightgray" for i in  1:78]
colors[42] = colorant"orange"

gplot(g, nodefillc=nodefillc, layout=circular_layout, edgestrokec=colors, edgelabel=1:78)

Which producesenter image description here

I would like to add a legend on top left (or top right) so that I can easily tell what are the meaning of the two types of edges. Additionally, if there is also a way to legend what are the two types of nodes that would be a great plus!

For instance, grey edges would be named: "regular edges" and green edges would be "backup edges". Similarly, grey nodes would be "regular nodes" and orange nodes would be "backup nodes"! I could not find a keyword in gplot for what I am searching!

0

There are 0 best solutions below