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.

Version 9.

When writing

Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, 
 PlotLegends -> Placed[TraditionalForm /@ {Sin[x], Cos[x]}, Right]]

The result is

enter image description here

Now I'd like to put the legend below the plot, but at the same time keep them looking the same way. i.e. sin(x) on top and cos(x) below. I do not want them to flatten. But when I do

Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, 
 PlotLegends -> Placed[TraditionalForm /@ {Sin[x], Cos[x]}, Bottom]]

The result is

enter image description here

I can't use Grid or such to format these myself in the way I like them, since if I do, then PlotLegend will not see them any more. i.e. I can't just write something like

Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, 
 PlotLegends -> Placed[ Column[{Sin[x], Cos[x]}], Bottom]]

enter image description here

Any one knows of a trick to do this? I looked at options for PlotLegend but do not see anything right away.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted
 Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, 
 PlotLegends -> Placed[LineLegend["Expressions", LegendLayout -> "Column"], Bottom]]

enter image description here

Update: the following (which does not explicitly use LineLegend in the input) also gives the same picture:

 Plot[{Sin[x], Cos[x]}, {x, -2 Pi, 2 Pi}, 
 PlotLegends ->  Placed[TraditionalForm /@ {Sin[x], Cos[x]}, Bottom]] /. 
   (LegendLayout -> _) :> LegendLayout -> "Column"

If you are certain that the strings "Row" and "Column" appear only in connection with legend layout in your plot, you can use the simpler replacement rule "Row" -> "Column".

share|improve this answer
add comment

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.