When is Evaluate needed within function arguments? [duplicate]

This question already has an answer here:

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}]

-

marked as duplicate by Szabolcs, Sjoerd C. de Vries, m_goldberg, rcollyer, Oleksandr R.Feb 14 '13 at 4:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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 –  The Toad 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. –  Guillochon 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... –  Guillochon 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. –  Xerxes Feb 2 '13 at 0:46

1 Answer

Try :

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

-
b.gatessucks: I ending up figuring this out too, so I modified my question to ask something related which still confuses me. –  Guillochon Feb 2 '13 at 0:12