# How to widen PlotLegends?

I have a plot whose legend, when placed at the bottom, is two lines rather than one:

Plot[{x, x^2}, {x, 0, 5}, PlotRange -> {0, 5}, PlotLegends -> Placed[Abs /@ {Subscript[a, 2]/Subscript[a, 1], Subscript[a, 3]/Subscript[a, 1]}, Below]]


If I do the same thing without the absolute value signs, it plots in a row as I'd like:

Plot[{x, x^2}, {x, 0, 5}, PlotRange -> {0, 5}, PlotLegends -> Placed[{Subscript[a, 2]/Subscript[a, 1], Subscript[a, 3]/Subscript[a, 1]}, Below]]


I'm guessing the absolute value signs make this slightly too wide, but putting the two legends side by side would clearly fit into the plot. I've spent a while digging through the documentation and cannot figure out how to do this - help would be appreciated!

• nice to meet you here :) – Yi Wang Jul 19 '14 at 16:24

I think it may be a bug. One can explicitly specify the layout of plot, for example,

LineLegend[{Red, Blue}, {Abs[Subscript[a, 2]/Subscript[a, 1]],
Abs[Subscript[a, 3]/Subscript[a, 1]]},
LegendLayout -> (Grid[{Flatten@#}] &)]


And here is the plotting function applying the above method:

Plot[{x, x^2}, {x, 0, 5},
PlotLegends ->
Placed[LineLegend[
Abs@{Subscript[a, 2]/Subscript[a, 1],
Subscript[a, 3]/Subscript[a, 1] },
LegendLayout -> (Grid[{Flatten@#}] &)], Below ]]


## LegendLayout -> {"Row", 1}

The option LegendLayout -> {"Row", 1} gives the desired result:

legend = LineLegend[Automatic, Abs /@ {Subscript[a, 2]/Subscript[a, 1],
Subscript[a, 3]/Subscript[a, 1]}, LegendLayout -> {"Row", 1}];

Plot[{x, x^2}, {x, 0, 5}, PlotRange -> {0, 5}, PlotLegends -> Placed[legend, Below]] This is not quite satisfactory but at least a row:

row[p_] :=
TableForm[p, TableAlignments -> Center, TableDirections -> Row]

leg :=
LineLegend[{Orange, Blue},