I don't get a legend when I use the option PlotLegends -> "Expressions" when the first argument to Plot is a single function. It works OK when I give Plot a list of functions.
Test cases:
Plot[Sin[x], {x, 0, 2 Pi}, PlotLegends -> "Expressions"]
ContourPlot[x^2 + y^2 == 1, {x, -2, 2}, {y, -2, 2}, PlotLegends -> "Expressions"]
=================================== 
Answer
This is an intentional change to make PlotLegends -> "Expressions" more consistent with PlotLegends -> Automatic. Both now do not produce legends when only one line is present. What you are looking for is PlotLegends -> "AllExpressions" which has the old behavior, e.g.
Plot[x, {x, 0, 1}, PlotLegends -> "AllExpressions"]

More generally, PlotLegends operates based on whether or not two plots are distinguishable. In other words, if there is no displayed difference between two plots, two legends won't be displayed. For example,
Plot[{x, x^2}, {x, 0, 1}, PlotStyle -> Blue, PlotLegends -> "Expressions"]

Contrast this with
Table[
Plot[{x, x^2}, {x, 0, 1}, PlotStyle -> Blue, PlotLegends -> legend, PlotLabel -> legend],
{legend, {"AllExpressions", All, "Placeholders", {a, b}}}
]

After the number of distinguishable plots are determined, that gives you the number of legends to expect, once the no single legend rule is accounted for. So, these all should give two legends,
Plot[{x, x^2, x^3}, {x, 0, 1}, PlotStyle -> {Blue, Green}, PlotLegends -> "Expressions"]

Table[
Plot[{x, x^2, x^3}, {x, 0, 1}, PlotStyle -> {Blue, Green},
PlotLegends -> legend, PlotLabel -> legend],
{legend, {"AllExpressions", All, "Placeholders", {a, b}}}
]

Comments
Post a Comment