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.

When using LegendLayout->"Row", with a lengthy row, I get line breaks. This would seemed logic if it was confined by another structure. But if happens even when there's no "confinement":

LineLegend[{Blue, Orange, Green}, {"this is a big test", 
  "this is a big test", "this is a big test"}, LegendLayout -> "Row"]

enter image description here

How can I change the ItemSize/ImageSize of the Legend?

(should this behavior be reported?)

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Tell it that you really want n rows by {"Row", n}, for example:

LineLegend[{Blue, Orange, Green}, {"this is a big test", 
"this is a big test", "this is a big test"}, 
LegendLayout -> {"Row", 1}]
share|improve this answer
    
This construct for LegendLayout really needs to be inside the documentation. It is extremely useful –  Jonie Jul 31 '13 at 1:07

To avoid line breaks You can use Grid insted (more here):

f[x_] := Grid[{Flatten@x}];

LineLegend[{Blue, Orange, Green}, {"this is a big test", 
 "this is a big test", "this is a big test"}, LegendLayout -> f]

Edit

Strange thing that I can not put pure function to LegendLayout option :/ If You don't want to define f outside, use: LegendLayout->Function[{x}, Grid@{Flatten@x}].

share|improve this answer
1  
try: LegendLayout -> (Grid[{Flatten@#}] &), that should do the trick (for the pure function that is) –  Pinguin Dirk Jun 1 '13 at 9:07
    
@PinguinDirk Ah, it does. I should have thought about this :p –  Kuba Jun 1 '13 at 9:13
1  
The reason you need the parentheses is & has a lower precedence than ->. If you run FullForm[q -> #&] you get Function[Rule[q, Slot[1]]], but add parentheses: FullForm[q -> (#&)] you get, Rule[q, Function[Slot[1]]]. –  rcollyer Jun 10 '13 at 14:14

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.