# When is Evaluate needed within function arguments? [duplicate]

I'm trying to do a simple variable substitution within a ContourPlot, but it's not working. Here's an example:

ContourPlot[x y == 1/2, {x, 0, 1}, {y, 0, 1}]
ContourPlot[x y == 1/2 /. y -> z, {x, 0, 1}, {z, 0, 1}]


The second line, although mathematically identical, produces no contour. Why? How can I do the substitution correctly?

Edit: It looks like my initial question is solved by simply wrapping the argument in Evaluate. However, why doesn't Plot obey the same rules? The following works without Evaluate:

Plot[x, {x, 0, 1}]
Plot[x /. x -> z, {z, 0, 1}]

• Please don't quickly change your question as soon as you get an answer. Duplicate of mathematica.stackexchange.com/q/1375/5, mathematica.stackexchange.com/q/1731/5, mathematica.stackexchange.com/q/3270/5 and several others
– rm -rf
Feb 2 '13 at 0:17
• Should I have just deleted the question and submitted a revised one? It's not clear to me why ContourPlot would have HoldAll, and Plot would not...and if there's a general rule for which routines have HoldAll or not. Feb 2 '13 at 0:25
• Alright, I guess both have HoldAll, from the links you provided. I'm still confused as to why the Plot command works without the Evaluate... Feb 2 '13 at 0:30
• ContourPlot has several "modes", one of which is to display contours corresponding to one or a list of equalities. Your expression is a ReplaceAll, so ContourPlot uses its default mode. (The ReplaceAll contains an equality, but ContourPlot doesn't see that.) In default mode, your expression evaluates to False or True, which are not real numbers, so nothing is displayed. Plot also has several modes, but your given expression works fine for the default one. Feb 2 '13 at 0:46

ContourPlot[Evaluate[x y == 1/2 /. y -> z], {x, 0, 1}, {z, 0, 1}]