# How to change layout of a legend in Show function?

I am trying to combine two plots using the Show function and have the resulting legend appear as a row. Using the LegendLayout function for each individual plot is not working. Below is my code:

Plot300 =
Plot[Exp[-0.03*t], {t, 0, 100},
PlotLegends -> LineLegend[{Style["Hello"]}, LegendLayout -> "Row"],
PlotStyle -> Blue];
Plot400 =
Plot[Exp[-0.03*t], {t, 0, 100},
PlotLegends ->
LineLegend[{Style["Hello2"]}, LegendLayout -> "Row"],
PlotStyle -> Green];
P1=Show[Plot300, Plot400]


Is there a straightforward solution to this problem? Any suggestions would be greatly appreciated!

• Are workarounds acceptable?
– bmf
Commented Apr 19, 2022 at 3:42
• @bmf Potentially, yes! Any suggestions would be helpful Commented Apr 19, 2022 at 3:48

One possible workaround is to use the Labeled function and build up a legend according to your requirements.

Plot300 = Plot[Exp[-0.03*t], {t, 0, 100}, PlotStyle -> Blue];
Plot400 = Plot[Exp[-0.09*t], {t, 0, 100}, PlotStyle -> Green];
P1 = Labeled[
Show[Plot300, Plot400]
, LineLegend[
{Blue, Green}
, {Style["Hello2"], Style["Hello"]}
, LegendLayout -> "Row"
]
, Bottom
]


• Why is the Labeled function needed here? Commented Apr 19, 2022 at 17:14
• I am not sure I understand your question. One of my thoughts, as I was composing this answer, was that it allows the addition of a legend independent of the plots.
– Syed
Commented Apr 19, 2022 at 17:42
• Oh I understand! Thank you so much Commented Apr 19, 2022 at 17:49
aux = {"Hi bmf", "Hi mathbioguy. I hope you'll find this useful"};
aux1 = Map[Style[#, 13] &, Table[aux[[i]], {i, 1, Length@aux}]];
pos = Bottom;
f1[x_] := Exp[-0.03*x]
f2[x_] := x^2
plot1 = Plot[f1[x], {x, -2, 2}, PlotRange -> {{-2, 2}, {0, 4}},
PlotLegends -> Placed[LineLegend[{aux[[1]]}], pos],
PlotStyle -> {Blue, Dashed, Thick}];
plot2 = Plot[f2[x], {x, -2, 2}, PlotRange -> {{-2, 2}, {0, 4}},
PlotLegends -> Placed[LineLegend[{aux[[2]]}], pos],
PlotStyle -> {Red, Thick}];
Show[plot1, plot2]