I have a graph with four curves and I want to custom order their appearance in the legend. In particular, in the graph below,
Plot[{(1 - bet) 1/(2 Sqrt[bet]), Sqrt[bet], bet^(1/4), (1 - bet) 1/(4 bet^(3/4))}, {bet, 0, 1},
PlotLegends -> Placed[{"MR1", "MC1", "MR2", "MC2"}, Below],
AxesLabel -> {"\[Beta]", "MR,MC"}, Ticks -> {Automatic, None},
Epilog -> {Inset[Text[Style["\!\(\*SuperscriptBox[\(\[Beta]\), \(*\)]\)",
FontSize -> 10]], {1/3, -0.075}],
Dashed, [{{1/3, 1/Sqrt[3]}, {1/3, 0}}]}]
the legends are showing up by row, but I would like them to show up by column instead like:
(blue) MR1 Lorem Ipsum (green) MR2 Lorem Ipsum
(orange) MC1 Lorem Ipsum (red) MC2 Lorem Ipsum
After searching hard, it seemed to me that I could switch the order of the curves and manually reassign colors from Wolfram's default colors like so:
Plot[{(1 - bet) 1/(2 Sqrt[bet]), bet^(1/4), Sqrt[bet], , (1 - bet) 1/(4 bet^(3/4))}, {bet, 0, 1},
PlotLegends -> Placed[{"MR1 lorem ipsum", "MR2 lorem ipsum", "MC1 lorem ipsum",
"MC2 lorem ipsum"}, Below], AxesLabel -> {"\[Beta]", "MR,MC"},
PlotStyle -> {{{RGBColor[0.368417`, 0.506779`, 0.709798`]}} ,
RGBColor[0.560181`, 0.691569`, 0.194885`],
RGBColor[0.880722`, 0.611041`, 0.142051`],
RGBColor[0.922526`, 0.385626`, 0.209179`]},
Ticks -> {Automatic, None},
Epilog -> {Inset[Text[Style["\!\(\*SuperscriptBox[\(\[Beta]\), \(*\)]\)",
FontSize -> 10]], {1/3, -0.075}], Dashed,
Line[{{1/3, 1/Sqrt[3]}, {1/3, 0}}]}]
which works for the application, but this would be extremely long and painful if there were many such curves. Generally, if one has a long list of curves in a graph but wants to customize the order of appearance of the legends, how does one do this? There must be a way to do this more conveniently than plotting first and then seeing how it looks, and then having to change the order manually and reassigning all the colors again. I'm new so please excuse if this question is too trivial / redundant. I tried reading seemingly related posts but couldn't find/understand the answer I was looking for. Many of them seemed to just talk about how to reverse the order. Thank you.
Update: Thank you all for your kind answers (sorry I don't have enough ref points to upvote yet). kguler's and belisarius' answers are correct; theirs transpose the legend matrix. I really like Mike Honeychurch's answer: it allows for custom ordering of the curves by simply referring to them by their index numbers, which is quite nice. Below is the implementation. But is there a way to use such a matrix index ordering method with LegendLayout(Grid@...)
?
Plot[{(1 - bet) 1/(2 Sqrt[bet]), bet^(1/4),
Sqrt[bet], (1 - bet) 1/(4 bet^(3/4))}, {bet, 0, 1},
PlotLegends ->
Placed[LineLegend[
ColorData[97, "ColorList"][[{1, 3, 2, 4}]], {"MR1 lorem ipsum",
"MC1 lorem ipsum", "MR2 lorem ipsum",
"MC2 lorem ipsum"}[[{1, 3, 2, 4}]]], Below],
AxesLabel -> {"\[Beta]", "MR,MC"},
PlotStyle -> ColorData[97, "ColorList"][[{1, 3, 2, 4}]], Ticks -> {Automatic, None}]
Update2: @kguler @belisarius @MikeHoneychurch Thank you all for your gracious help.
LegendLayout -> [[{1, 3, 2, 4}]]]
rather thanLegendLayout -> (Grid@Transpose@Partition[Row /@ #, 2] &)
but that doesn't work. $\endgroup$