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};
legend = SwatchLegend[Last /@ colors,
Row[{#[[1]], ": ", #[[2]]}] & /@ Transpose[{labels, names}][[All, All, -1]],
LegendMarkers -> "Bubble"];
You can use Legended
, Epilog
or Row
to add legends to a Graph
:
Legended[Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1}, VertexSize -> 0.1,
VertexStyle -> colors, VertexLabels -> labels, ImagePadding -> 20],
legend]
Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1},
VertexStyle -> colors, VertexSize -> 0.1, VertexLabels -> labels,
ImagePadding -> 20,
Epilog -> Inset[legend, {.75, .75}]]
Row[{Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1}, VertexStyle -> colors, VertexSize -> 0.1,
VertexLabels -> labels, ImagePadding -> 20, ImageSize -> 300],
legend}]