# Why does putting Eliminate in ContourPlot not plot anything?

I'm having an issue with my code. I will be trying to eliminate variables from a system of simultaneous equations and just trying to plot 2 of them. In the simplest example, I am hoping the following will plot the line $$y = x$$:

ContourPlot[Eliminate[{x == z, z == y}, z], {x, -5, 5}, {y, -5, 5}]

But it just returns the blank square. What is the syntax for actually plotting the correct $$x, y$$ points that solve the equation?

• Your code makes no sense. Try Eliminate[{x == z, z == y}, z] which gives y = x, which is certainly not in any form appropriate for ContourPlot. Commented Aug 9, 2021 at 0:27
• ContourPlot[ Eliminate[{x == z, z == y}, z] // Evaluate, {x, -5, 5}, {y, -5, 5}] Commented Aug 9, 2021 at 1:53
• ContourPlot holds the code (does not let it evaluate) and inspects the Head[] of the code to determine what sort of contour plot will be constructed. The Head in your case is Eliminate, and it does not know what to do with it. Hence, @cvgmt's solution. Commented Aug 9, 2021 at 4:15

With[{e = Eliminate[{x == z, z == y}, z]},

Evaluating Trace[ContourPlot[Eliminate[{x == z, z == y}, z], {x, -5, 5}, {y, -5, 5}]] (output not shown here because it is large) shows that the Eliminate does not get evaluated inside ContourPlot.
Meanwhile, Trace[With[{e = Eliminate[{x == z, z == y}, z]}, ContourPlot[e, {x, -5, 5}, {y, -5, 5}]]] shows that e gets set to the result of Eliminate[{x == z, z == y}, z] early on in the computation.