Skip to main content
2 of 3
added 484 characters in body
kglr
  • 400.5k
  • 18
  • 488
  • 929
labels = Table[i -> Style[Subscript[v, i], 20], {i, 3}]
names = Table[i -> "longname_" <> "v_" <> ToString@i, {i, 3}];
colors = {1 -> Blue, 2 -> Red, 3 -> Green}; 

You can use Legended or Epilog to add legends to a Graph:

Legended[ Graph[{1 <-> 2, 2 <-> 3,  3 <-> 1},
  VertexStyle -> colors, VertexSize -> 0.1, 
  VertexLabels -> labels, ImagePadding -> 20],
 SwatchLegend[Last /@ colors, 
  Row[{#[[1]], ": ", #[[2]]}] & /@ Transpose[{labels, names}][[All, All, -1]],
  LegendMarkers -> "Bubble"]]

enter image description here

Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1},
    VertexStyle -> colors, VertexSize -> 0.1, VertexLabels -> labels, 
    ImagePadding -> 50, 
 Epilog -> Inset[SwatchLegend[Last /@ colors, 
    Row[{#[[1]], ": ", #[[2]]}] & /@ Transpose[{labels, names}][[All, All, -1]],
    LegendMarkers -> "Bubble"], {.75, .75}]]

enter image description here

kglr
  • 400.5k
  • 18
  • 488
  • 929