ContourPlot
seems to be based on the Intermediate Value Theorem. It finds points greater or less than the contour level, or in your case, where the value of the left hand side is greater and where it is less than the right hand side -- unless it is lucky enough to find points where the equation is satisfied exactly. In your third example (x + y + 2)^2 == 0
, the left hand side is positive except along the line.
Sometimes you can get around this by putting in extra points:
ContourPlot[(x + y + 2)^2 == 0, {x, -3, 3}, {y, -3, 3},
PlotPoints -> {Automatic, Table[{x, -2 - x}, {x, -3, 3, 0.01}]}]
But it presupposes that you more or less know how to plot the contour. So why use ContourPlot
? The trick doesn't work so well for curves either.
Edit
Now if the function factors and you're only looking for the zero set, you can try the following.
g = x y^6 + y^7 + 2 x y^3 Sin[x] + 2 y^4 Sin[x] + x Sin[x]^2 + y Sin[x]^2;
ContourPlot[Evaluate[Times @@ First /@ Rest@FactorList[g] == 0], {x, -3, 3}, {y, -3, 3}]
It's somewhat nicer, if you don't mind the factors getting different colors, like this:
ContourPlot[Evaluate[First[#] == 0 & /@ Rest@FactorList[g]], {x, -3, 3}, {y, -3, 3}]