# How can I have PlotLegends showing the legend on a single line instead of two?

I am using PlotLegends in a Plot command to label each line of my plot (it has 4 different functions plotted) but the legend is split in two lines. I would like it two appear in a single line so it has the same appearance as the other plots displayed next to it. Is there a way to do that? I guess reducing the font size would be an option but I don't know how to do it.

I don't know if this is relevant, but afterwards I export the plot to an EPS file using the command

Export["swp_c0.eps", c0plt]


so maybe increasing the resolution might solve my problem.

UPDATE

I reduced the font size and still couldn't get it in one line. However, when I changed my legend labels from scientific notation (10^-2, using the -2 as a superscript) to fixed point notation (0.01) it worked (with the reduced font size). Here there is the final result so I managed to get it working. However, I would like, if possible, to understand what was the problem.

• PlotLegends -> LineLegend["Expressions", LegendLayout -> "Row"] ? – BlacKow Mar 15 '16 at 18:22
• It doesn't work. Using "Column" displays them as a column but using "Row" doesn't change anything. – Ferran Brosa Planella Mar 15 '16 at 18:27
• Can you post more details... maybe your plot as is – BlacKow Mar 15 '16 at 18:28

You can use the option setting LegendLayout -> {"Row", 1} inside LineLegend to have all legends in a single row:

Plot[Evaluate[Sin[# x] & /@ Range[7]], {x, 0, 2 Pi},
PlotLegends -> Placed[LineLegend["Expressions", LegendLayout -> {"Row", 1}], Above]]


Or, use a custom function as the setting for this option to organize legends in a Grid with a single row:

Plot[Evaluate[Sin[# x] & /@ Range[7]], {x, 0, 2 Pi},
PlotLegends -> Placed[LineLegend["Expressions",
LegendLayout -> (Grid[{Flatten@Riffle[#, Spacer[3]]}] &)], Above]]


Place the legends Above | Top or Below | Bottom, e.g.,

Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi},
PlotLegends -> Placed["Expressions", Above]]


• If you run InputForm@Plot[...][[2]], you'll notice that this sets LegendLayout -> "Row". :) – rcollyer Mar 15 '16 at 18:51