Message Boards Message Boards

ContourPlot: explicit vs variable-defined from of equations

I have:

equaz = {-4 + y == 0, 13 + 5 x + 3 y == 0, 23 + 7 x + 3 y == 0,  9 + 5 x - y == 0, 11 + 7 x - y == 0, 2 + x == 0, -1 + 7 x + 9 y == 0,  5 + x + 3 y == 0, 3 + y == 0, 3 + 7 x + y == 0, 3 + x + y == 0}

why, if I type in an explicit form, it works and if I type the reference "equaz", it does not work?

ContourPlot [{-4 + y == 0, 13 + 5 x + 3 y == 0, 23 + 7 x + 3 y == 0,  9 + 5 x - y == 0, 11 + 7 x - y == 0, 2 + x == 0, -1 + 7 x + 9 y == 0,  5 + x + 3 y == 0, 3 + y == 0, 3 + 7 x + y == 0, 3 + x + y == 0}, {x, -20, 30}, {y, -20, 30}]

-> work

ContourPlot [equaz, {x, -20, 30}, {y, -20, 30}]

-> don't work, white graph

tnk's

POSTED BY: Mutatis Mutandis
3 Replies

Work! Tnk's

POSTED BY: Mutatis Mutandis

The way ContourPlot works, the numerical values of x,y are replaced in equaz before equaz is expanded to its definition. Since the unevaluated symbol equaz does not contain x,y, nothing happens. You can solve the problem with Evaluate:

ContourPlot[Evaluate@equaz, {x, -20, 30}, {y, -20, 30}]

It is somewhat confusing, because better-known functions like Plot work in a different way:

f = {3 x, Sin[x]};
Plot[f, {x, 0, Pi}]
POSTED BY: Gianluca Gorni

Hi,

I seem to remember that there was another post about a similar thing. It appears that the order of the evaluation has been changed, i.e. the Hold/Defer structure. This one does work:

ContourPlot[Evaluate[equaz], {x, -20, 30}, {y, -20, 30}]

I also prefer the "old way of doing it".

Best wishes,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract