1
$\begingroup$

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.

$\endgroup$

2 Answers 2

6
$\begingroup$

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:

enter image description here

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.

$\endgroup$
0
3
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Thanks! A couple of points: (1) Can I make the legends bigger? (2) Can they be left-aligned? $\endgroup$
    – Alex
    Mar 27, 2015 at 20:58
  • $\begingroup$ 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]] $\endgroup$
    – penguin77
    Mar 27, 2015 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.