2
$\begingroup$

I have a feeling this question has been asked before but here it is in the simplest form:

Plot[
 {0.3 x^2, 0.5 x^2, 0.7 x^2}, {x, -3, 3},
 PlotLegends -> "Expressions"
 ]

enter image description here

I tried the AbsoluteOptions@ Plot[{0.3 x^2, 0.5 x^2, 0.7 x^2}, {x, -3, 3}, PlotLegends -> "Expressions"] but could not find something to work with.

Question What I want to do is to write out the legend in reverse order so that colors match up. Is there a built-in option to rearrange PlotLegends entries.

Thanks.

$\endgroup$
1
  • 1
    $\begingroup$ Or reverse the order of the functions, i.e., Plot[Evaluate[Reverse@{0.3 x^2, 0.5 x^2, 0.7 x^2}], {x, -3, 3}, PlotLegends -> "Expressions"] $\endgroup$
    – Bob Hanlon
    Oct 1 '21 at 15:00
5
$\begingroup$

Use LineLegend with the option LegendLayout -> "ReversedColumn":

Plot[{0.3 x^2, 0.5 x^2, 0.7 x^2}, {x, -3, 3}, 
 PlotLegends -> LineLegend["Expressions", LegendLayout -> "ReversedColumn"]]

enter image description here

Note: LegendLayout -> Grid @* Reverse gives the same result.

$\endgroup$
2
  • $\begingroup$ Thanks. PlotLegends do appear in the Options[Plot] but not in AbsoluteOptions that I tried. What is the main difference between the two? Is there a hierarchy diagram I can study that can clarify the relationships between Plot and its various options? $\endgroup$
    – Syed
    Oct 1 '21 at 12:41
  • $\begingroup$ @Syed, the short tutorial Manipulating Options may be useful. $\endgroup$
    – kglr
    Oct 1 '21 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.