# How create a data list of x,y,z values

ListContourPlot[Table[Sin[i + j^2], {i, 0, 2, .1}, {j, 0, 5, .1}]]
ListContourPlot[
Table[{i, j, Sin[i + j^2]}, {i, 0, 2, .1}, {j, 0, 5, .1}]]
Table[{i, j, Sin[i + j^2]}, {i, 0, 2, .5}, {j, 0, 5, 1.}]


Simple example The first produces nice contours with axes the array row and column numbers or in this case 10*i and 10*j

The second produces an empty graph with correct i and j on the axes.

The third test table has 1 too many pairs of brackets is not a simple list of x,y,z values for the non-array version of Counterplot list argument. as in the non-array version ListContourPlot[{{x1,y1,f1},{x2,y2,f2},…}] Please How do I generate the list that ContourListPlot wants please

• You might also be interested in the DataRange->{...} option for plots. I find it useful, especially if I need to plot the same data generated elsewhere in different units for instance. You would use this with your first example as: ListContourPlot[Table[Sin[i+j^2],{i,0,2,0.1},{j,0,5,0.1},DataRange->{{0,5},{0,2}}] – N.J.Evans Mar 31 '17 at 13:06

Are you looking for something like this?

f[i_, j_] := Sin[i + j^2];

data1 = Flatten[ Table[{i, j, N[f[i, j]]}, {i, 0, 2, 0.1}, {j, 0, 5, 0.1}], 1];

data2 = Flatten[ Table[{i, j, N[f[i, j]]}, {i, 0, 2, 0.5}, {j, 0, 5, 1}], 1];

ListContourPlot[data1]


ListContourPlot[{data1, data2}]


• I am very grateful to you. I refined this down to ListContourPlot[Table[Sin[i + j^2], {i, 0, 2, .1}, {j, 0, 5, .1}]] corrected axes by ListContourPlot[ Flatten[Table[{x, y, Sin[y + x^2]}, {y, 0, 2, 0.1}, {x, 0, 5, 0.1}], 1]] – simon Mar 31 '17 at 12:33

I'm not sure I get it right. The following expression (with Flatten)

ListContourPlot[Flatten[Table[{i, j, Sin[i + j^2]}, {i, 0, 2, .5}, {j, 0, 5, 1.}], 1]]


gives:

Grateful to Maple SE. The second and thrird now correct the axes labelling of the first.

ListContourPlot[Table[Sin[i + j^2], {i, 0, 2, .1}, {j, 0, 5, .1}]]
ListContourPlot[
Flatten[Table[{j, i, Sin[i + j^2]}, {i, 0, 2, 0.1}, {j, 0, 5, 0.1}],
1]]
ListContourPlot[
Flatten[Table[{x, y, Sin[y + x^2]}, {y, 0, 2, 0.1}, {x, 0, 5, 0.1}],
1]]


Note I dropped Maple's N without change and transposed {j,i,Sin.. In the third I changed to x and y to emphasise how the y loop is the inner and x is the outer. Without automatic labeling of the axes I hadn't noticed before that the original tutorial example has 10j horizontally and 10i vertically which is counter to convention

I had tried Flatten before asking but didn't know of the final argument ,1]