2
$\begingroup$

I don't understand how the first of the basic examples in the documentation on ListPlot3D is generating the plot that it does.

ListPlot3D[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 2, 1, 4}},  Mesh -> All]

plot

Which of these values is it taking as $x$, $y$ and $z$ values and what is the fourth value in each set used for? I'm trying to learn Mathematica with zero previous knowledge of arrays, so I don't know if that's the problem or if I'm misunderstanding some completely different aspect.

$\endgroup$
8
  • 3
    $\begingroup$ From the details: In ListPlot3D[array], array must be a rectangular array. Each element can be either a single real number representing a value, or an (x, y, z) triple. There will be holes in the surface corresponding to array elements that do not represent explicit height values. ListPlot3D[array] by default takes the x and y coordinate values for each data point to be successive integers starting at 1. $\endgroup$
    – b3m2a1
    Jan 2, 2018 at 16:50
  • $\begingroup$ @b3m2a1 So then in the example because they aren't triples then each element is a z value: ListPlot3D[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 2, 1, 4}}, Mesh -> All] and it's assigning x and y co-ordinates in integer steps? So would the first element, 1, be assigned x=1,y=1 and the sixth element is x=6,y=6? $\endgroup$
    – user13948
    Jan 2, 2018 at 16:56
  • 2
    $\begingroup$ Yeah. The array basically unfurls to this: MapIndexed[Append[#2, #] &, {{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 2, 1, 4}}, {2}]//Flatten[#, 1]&. But the Interpolation is different. You can see the first uses only the array as the mesh whereas using that array gives a full Mesh (b.c. it interpolates differently, I think) $\endgroup$
    – b3m2a1
    Jan 2, 2018 at 16:59
  • $\begingroup$ @b3m2a1 So, if I've got this right, it ignores subgroupings? It ignores the fact that the numbers come in sets of four and just makes it into one list of z values? $\endgroup$
    – user13948
    Jan 2, 2018 at 17:10
  • 3
    $\begingroup$ I think not quite. Unless I misunderstood the docs, it uses the array indexing, i and j, as x and y. $\endgroup$
    – b3m2a1
    Jan 2, 2018 at 17:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.