Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Axes in Plot3D and ListPlot3D

283 views
Skip to first unread message

Ray Koopman

unread,
Jun 17, 2013, 6:13:26 AM6/17/13
to
Plot3D[Sin[x + y^2],{x,-3,3},{y,-3,3},AxesLabel->{"x","y","z"}]

gives a plot that I thought I could duplicate by creating a table

z = Table[Sin[x + y^2],{x,-3,3,1/4},{y,-3,3,1/4}];

and then using ListPlot3D:

ListPlot3D[z,AxesLabel->{"x","y","z"},MeshRange->{{-3,3},{-3,3}}] .

That gives a different view of the same surface, with the wrong labels
on the axes. To duplicate the Plot3D result I must transpose the array:

ListPlot3D[Transpose@z,AxesLabel->{"x","y","z"},MeshRange->{{-3,3},{-3,3}}]

That seems unreasonable. What have I missed?
Is it mentioned somewhere in the documentation?

Bob Hanlon

unread,
Jun 19, 2013, 1:22:54 AM6/19/13
to

Just include the coordinates in the Table


data = Flatten[
Table[{x, y, Sin[x + y^2]}, {x, -3, 3, 1/16}, {y, -3, 3, 1/16}], 1];


ListPlot3D[data, AxesLabel -> {"x", "y", "z"}]



Bob Hanlon

Tomas Garza

unread,
Jun 19, 2013, 1:23:34 AM6/19/13
to

The explanation lies in how Table constructs the array. The definition in the Help browser says


Table[expr,{i,Subscript[i, min],Subscript[i, max]},{j,Subscript[j, \

min],Subscript[j, max]},=85] gives a nested list. The list associated with i is \

outermost.


This is, I agree, contrary to what happens with a double integral, where the inner integral goes first. And, of course, it is not consistent with the way Plot3D works.


-Tomas


> From: koo...@sfu.ca
> Subject: Axes in Plot3D and ListPlot3D
> To: math...@smc.vnet.net
> Date: Mon, 17 Jun 2013 06:25:11 -0400
>
> Plot3D[Sin[x + y^2],{x,-3,3},{y,-3,3},AxesLabel->{"x","y","z"}]
>
> gives a plot that I thought I could duplicate by creating a table
>
> z = Table[Sin[x + y^2],{x,-3,3,1/4},{y,-3,3,1/4}];
>
> and then using ListPlot3D:
>
> ListPlot3D[z,AxesLabel->{"x","y","z"},MeshRange->{{-3,3},{-3,3}}] .
>
> That gives a different view of the same surface, with the wrong labels
> on the axes. To duplicate the Plot3D result I must transpose the array:
>
> ListPlot3D[Transpose@z,AxesLabel->{"x","y","z"},MeshRange->{{-3,3},{-3,3}}]

Ray Koopman

unread,
Jun 20, 2013, 4:00:53 AM6/20/13
to
Thanks. I was basically looking for confirmation that I hadn't
overlooked something in the documentation. The transposition of the
first two dimensions, compared to their interpretation in Plot3D, is
something that I think ought to be mentioned explicitly as the second
item in the Details section of the documentation, imediately after

In ListPlot3D[array], array must be a rectangular array. Each element
can be either a single real number representing a z value, or an {x,y,z}
triple.

----- Tomas Garza <tgar...@msn.com> wrote:
> The explanation lies in how Table constructs the array.
> The definition in the Help browser says
>
> Table[expr,{i,Subscript[i, min], Subscript[i, max]},
> {j,Subscript[j, min], Subscript[j, max]}, ] gives a nested list.
0 new messages