# How to make legends in Graphics?

To make an equilateral hexagon, here is my code in mathematica:

Graphics[{Thick, Black, Line[{
{0, 2/Sqrt[5]},
{1/Sqrt[5], 4/Sqrt[5]},
{1 + 1/Sqrt[5], 4/Sqrt[5]},
{1 + 2/Sqrt[5], 2/Sqrt[5]},
{1 + 1/Sqrt[5], 0}, {1/Sqrt[5], 0},
{0, 2/Sqrt[5]}}], Black, Inset[Text[Style["1", Large]], {0, 2/Sqrt[5]}, Scaled[{.9, .5}]], Black, Inset[Text[Style["2", Large]], {1/Sqrt[5],4/Sqrt[5]},Scaled[{.5, .1}]], Black, Inset[Text[Style["3", Large]], {1 + 1/Sqrt[5], 4/Sqrt[5]}, Scaled[{.5, .1}]], Black, Inset[Text[Style["4", Large]], {1 + 2/Sqrt[5], 2/Sqrt[5]}, Scaled[{-0.2, .5}]], Black, Inset[Text[Style["5", Large]], {1 + 1/Sqrt[5], 0}, Scaled[{.5, .9}]], Black, Inset[Text[Style["6", Large]], {1/Sqrt[5], 0}, Scaled[{.5, .9}]]}]


I want to make legends for numbers 1 to 6. How can I do that? Thanks.

Here is a more formatted and styled legend:

Legended[
grp,
SwatchLegend[{Green, Blue, Red, Brown, Black, Orange}, {"A ", "B ",
"C ", "D ", "E ", "F "}, LegendMarkerSize -> {{30, 30}},
LegendMarkers -> (Graphics[Text[Style[#, 20, Bold]],
ImageSize -> 15] & /@ Range[6]), LegendFunction -> "Panel"]]


it looks like this:

instead of the 6 Colors you can use

 ConstantArray[Black, 6]


to make the numbers just Black, use LegendMarkerSize to control the over-all size of the legend.

Easy as this...

Legended[grp,
Grid[{Range @ 6, {"this", "asd", "asdf", "blabla", "af", "asd"}} //
Transpose]]


grp is your Graphics, obviously. You may fiddle around with Grid at your will for formatting....hi,hi,hi

• Thanks! A couple of points: (1) Can I make the legends bigger? (2) Can they be left-aligned?
– Alex
Mar 27 '15 at 20:58
• On Grid you can do any thinkable formatting, please have a quick lock at the documented options for Grid . Legended[grp, Magnify[Grid[{Range @ 6, {"this", "asd", "asdf", "blabla", "af", "asd"} } // Transpose, Alignment -> Left], 3]] Mar 27 '15 at 21:02