# ContourPlot not evaluating correctly [duplicate]

When I try to plot an evaluated equation with contour plot in Mathematica 9, but do so with a variable, the plot is empty, but when I input the evaluated equation itself, the ContourPlot plots correctly. Everything worked fine in Mathematica10.

Here's my equations

table2b =
Evaluate[
Table[
Evaluate@eq2, {P, {-4, -2, 0, 2, 4}}, {n, {.1, .1}}, {α, {1, 1}}, {ρ, {.1, .1}}]];

plotpoints = 200;

fulltable = Union[Flatten[table2b]]

ContourPlot[fulltable, {p, -1, 15}, {q, -100, 100},
PlotPoints -> plotpoints, PlotRange -> All, Axes -> True]


This gives me an empty box. However, when I plug in directly the evaluated version of fulltable, everything plots correctly. The evaluated fulltable is below.

{-4 + p - q ==
1 + (1. (p - q))/q - 0.464159 (q/(p - q))^(1/3), -2 + p - q ==
1 + (1. (p - q))/q - 0.464159 (q/(p - q))^(1/3),
p - q == 1 + (1. (p - q))/q - 0.464159 (q/(p - q))^(1/3),
2 + p - q == 1 + (1. (p - q))/q - 0.464159 (q/(p - q))^(1/3),
4 + p - q == 1 + (1. (p - q))/q - 0.464159 (q/(p - q))^(1/3)}

• You haven't included the definition of eq2 (please, do so), but I note that you use a capital P in the Table, whereas you use a lowercase p in the plot. Mathematica is case sensitive... BTW All those evaluates shouldn't be necessary (generally). May 31, 2015 at 21:27
• Try using CubeRoot or Surd instead of ^(1/3). The one-third power may be giving you complex values. May 31, 2017 at 9:05

I'm somewhat sure that this issue depends on the Mathematica version you are using. What you have to understand is that ContourPlot has the attribute HoldAll which indicates that arguments like your fulltable are not evaluated to the list of equations it contains.

Since this leads to empty plots which give new users a hard time, I guess Wolfram included some more sophisticated tests in newer versions of Mathematica to see whether users provided a variable that contains the list of equations.

The conclusion is that the following code works fine in V10, but does show an empty plot in V8.

expr = {Cos[x] + Cos[y] == 1/2};
ContourPlot[expr, {x, 0, 4 Pi}, {y, 0, 4 Pi}]


To make it work in V8, please wrap an Evaluate around expr in the contour plot. This should solve the issue with your real problem too then.

• Somewhere between V10 and V12 things changed again. In V12 one needs ContourPlot[Evaluate[expr],...]. May 17, 2021 at 3:31