Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to create a single column LineLegend with at least 12 different entries. Suppose that I define lists colors and names as follows:

colors = {Red, Magenta, Pink, Orange, Yellow, Green, Darker[Green], 
   Cyan, Blue, Purple, Black, Gray};
names = Table["Color " <> ToString[i], {i, 1, Length[colors]}];

If I use colors[[;; 10]] to show only the first 10 entries in LineLegend with LegendLayout -> "Column", I get a nice single column LineLegend:

LineLegend[colors[[;; 10]], names, LegendLayout -> "Column", 
 LabelStyle -> {20, FontFamily -> "Arial"}]

singleColumn

However, if I show 11 or more entries, the legends become double-columned:

LineLegend[colors[[;; 11]], names, LegendLayout -> "Column", 
 LabelStyle -> {20, FontFamily -> "Arial"}]

doubleColumn1

LineLegend[colors, names, LegendLayout -> "Column", 
 LabelStyle -> {20, FontFamily -> "Arial"}]

doubleColumn2

How can I force LineLegend to put the legend entries in a single column?

share|improve this question
2  
f[pairs_] := Grid[pairs]; LineLegend[colors, names, LegendLayout -> f, LabelStyle -> {20, FontFamily -> "Arial"}] gives !Mathematica graphics –  Nasser Apr 12 at 17:09

1 Answer 1

up vote 4 down vote accepted

You can define a layout function as shown in the documentation :-

colors = {Red, Magenta, Pink, Orange, Yellow, Green,
   Darker[Green], Cyan, Blue, Purple, Black, Gray};
names = Table["Color " <> ToString[i], {i, 1, Length[colors]}];

table[pairs_] := TableForm[pairs, TableAlignments -> Left,
   TableSpacing -> {2, 1}];

LineLegend[colors[[;; 11]], names, LegendLayout -> table, 
 LabelStyle -> {20, FontFamily -> "Arial"}]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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