# Plotting equations stored in a variable [duplicate]

The following produces an empty plot:

eqn = x^2 + y^2 == 1;
ContourPlot[eqn, {x, -1, 1}, {y, -1, 1}]


Whereas the following plots a circle, as expected:

ContourPlot[x^2 + y^2 == 1, {x, -1, 1}, {y, -1, 1}]


What do I need to do to get the former to work with eqn? My actual eqn is a complicated list of equations.

I am sure this is elementary...

• ContourPlot[Evaluate@eqn, {x, -1, 1}, {y, -1, 1}] Aug 18, 2016 at 18:54
• @MichaelE2: Ah, thanks! Is there a short explanation of why Evaluate is needed here? Is it because ContourPlot has attribute HoldAll? Aug 18, 2016 at 18:56
• I found an explanation here. Thanks! Aug 18, 2016 at 19:07
• Yep, you found it. All commands that plot functions or equations are HoldAll. In this specific case, ContourPlot sees the unevaluated symbol eqn and decides it's a function, not an equation, because the Head is Symbol and not Equal. (I think it could be changed so that Evaluate is not needed in this case, but until it's changed, Evaluate is what you have to use.) Aug 18, 2016 at 19:18
• @user21: Yes, I linked to that in a comment above. It is a duplicate, and there is a clear explanation there by two users. Aug 18, 2016 at 21:31