Colors in the plot legend are wrong

When I plot multiple curves with ContourPlot I get different colors between the curves and the legend. This is an issue that emerged from the Edit part of the Answer to this post. The code is this:

Clear["Global*"]
n = 1;
eqns[i_, b_] = {D[w - 1/((1 - e) w), e] == D[1 - e, e] ((-((-a (i + ((1 - e) n (w/(b e^b))^(1/(b - 1)))/(1 - n e (w/(b e^b))^(1/(b - 1)))) + (-1 + a^2) (-1 + e)^2 w - a (-1 + e) (i + ((1 - e) n (w/(b e^b))^(1/(b - 1)))/(1 - n e (w/(b e^b))^(1/(b - 1)))) w^2)/(a (-1 + e) i (1 - e + i + ((1 - e) n (w/(b e^b))^(1/(b - 1)))/(1 - n e (w/(b e^b))^(1/(b - 1)))) w))) - (-((-a ((1 - e) n (w/(b e^b))^(1/(b - 1)))/(1 - n e (w/(b e^b))^(1/(b - 1))) + (-1 + a^2) (-1 + e) (-1 + e - i) w - a (-1 + e) ((1 - e) n (w/(b e^b))^(1/(b - 1)))/(1 - n e (w/(b e^b))^(1/(b - 1))) w^2)/(a (-1 + e) i (1 - e + i + ((1 - e) n (w/(b e^b))^(1/(b - 1)))/(1 - n e (w/(b e^b))^(1/(b - 1)))) w)))), D[e, w] == e/w, r == w/(a e), 0 <= i <= 1, 0 <= a <= 1, 0 <= e <= 1, w >= 0, 0 <= b <= 1};

colors = ColorData[97] /@ Range[3];

ContourPlot[
Evaluate@Table[Simplify@eqns[1/10, 7/10], {a, {2/10, 8/10}}], {w, 0, 5}, {e, 0, 1}, ContourStyle -> colors, PlotPoints -> 50, MaxRecursion -> 4, FrameLabel -> (Style[#, 14] & /@ {w, e}), RotateLabel -> False, PlotLegends -> Placed[LineLegend[colors, {2/10, 8/10}, LegendLabel -> "a ="], {.7, .4}]]


where I plotted two cases, $$a=0.2$$ and $$a=0.8$$, for the relation between $$w$$ and $$e$$, and the result is this:

As you can see, the colors of the plots and legends are different, green and orange!

• Recommendation in the future: Post the MINIMAL code that illustrates your problem. Do we really need the entire complicated equations? Feb 17, 2023 at 18:38
• ...or that the figure is rotated? or that it has a particular Label? or the FrameLabel has a particular style? or that the FrameLabel is explicitly not rotated? And why or why oh why do you define $n=1$ and then include it in your equations!!!? Feb 17, 2023 at 19:38

You should be plotting eqns[1/10,7/10][[1]]. You are cycling through the non-plottable elements of eqns[1/10,7/10]

ContourPlot[
Evaluate@Table[Simplify@eqns[1/10, 7/10][[1]], {a, {2/10, 8/10}}], {w, 0,
5}, {e, 0, 1}, PlotPoints -> 50, MaxRecursion -> 4,
FrameLabel -> (Style[#, 14] & /@ {w, e}), RotateLabel -> False,
PlotLegends ->
Placed[LineLegend[{2/10, 8/10}, LegendLabel -> "a ="], {.7, .4}]]
`

• thanks so much!
– ppp
Feb 19, 2023 at 23:44