Bug introduced in 10.1 or earlier and persisting through 11.0.1 or later
Consider:
f[x_, y_] = x^2 + y^2;
g[x_, y_] = x^4 + y^4;
critPts =
Solve[{Grad[f[x, y], {x, y}] == \[Lambda] Grad[g[x, y], {x, y}],
g[x, y] == 1}, {x, y, \[Lambda]} \[Element] Reals]
Then:
ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2},
PlotLegends -> Automatic,
MeshFunctions -> Function[{x, y}, g[x, y]],
Mesh -> {{1}},
MeshStyle -> {Thick, Yellow},
Epilog -> {
Red, PointSize[Large], Point[{x, y}] /. critPts
}]
Which produces this image:
Now, we add specific contours.
ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2},
Contours -> {1, Sqrt[2]},
PlotLegends -> Automatic,
MeshFunctions -> Function[{x, y}, g[x, y]],
Mesh -> {{1}},
MeshStyle -> {Thick, Yellow},
Epilog -> {
Red, PointSize[Large], Point[{x, y}] /. critPts
}]
Which produces this image.
Now, if you hover your mouse over the two contours, tooltip labels of 1 and $\sqrt2$ appear.
Now consider this:
ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2},
Contours -> {1, Sqrt[2], 3},
PlotLegends -> Automatic,
MeshFunctions -> Function[{x, y}, g[x, y]],
Mesh -> {{1}},
MeshStyle -> {Thick, Yellow},
Epilog -> {
Red, PointSize[Large], Point[{x, y}] /. critPts
}]
Which produces this image.
Now, hover your mouse over each contour and you will see the incorrect tooltip labels pop up.
Is this a bug?
ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}, Contours -> {1, Sqrt[2], 3}]
toContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}, Contours -> {1, N@Sqrt[2], 3}]
. $\endgroup$