Message Boards Message Boards

0
|
9749 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

3D List plot from a 2D array (Matrix)?

Posted 7 years ago

Hello, Let's assume I have something like this

xcoor = Range[1, 2, 1/2];
ycoor = Range[3, 4, 1/2];
(x + y /. x -> xcoor) /. y -> ycoor

These can be values of a 2D function (xcoor,ycoor) for given x and y coordinates. I can't use directly the function for plotting for IP reasons. I can only use the points that are evaluated at and I would like to have a plot looking like this

data1 = Flatten[
Table[{r Cos[t], r Sin[t], 5 Sinc[r]}, {r, 0, 10, 0.5}, {t, -Pi, 
3 Pi, 0.1}], 1];
data2 = ExampleData[{"Geometry3D", "Torus"}, "VertexData"];
ListPointPlot3D[data1]

enter image description here

I could not find a way to do that, I was unable to convert that list to a table. I know there should be one.

Thank you

POSTED BY: Erdem Uguz
6 Replies
Posted 7 years ago

Hello Okkes,

It is almost what I want here I added a line to your suggestion but there are still two issues. First if you look at the plot the ticks are wrong, I can't see the correct values that.

xcoor = Range[1, 2, 1/20];
ycoor = Range[3, 4, 1/30];
vals = (x + y /. x -> xcoor) /. y -> ycoor;
vals = Transpose[{Flatten[vals]}];
coor = Tuples[{xcoor, ycoor}];
ListPointPlot3D[Partition[Thread[{coor, vals}] // Flatten, 21]]

Above is working but if I change to

xcoor = Range[1, 2, 1/20];
ycoor = Range[3, 4, 1/30];
vals = (x + y /. x -> xcoor) /. y -> ycoor;
vals = Transpose[{Flatten[vals]}];
coor = Tuples[{xcoor, ycoor}];
ListPointPlot3D[Partition[Thread[{coor, vals}] // Flatten, 21]]

enter image description here

This is not going to work.

POSTED BY: Erdem Uguz
Posted 7 years ago

I believe this is what you want. Replace 21 by 3.

xcoor = Range[1, 2, 1/20];
ycoor = Range[3, 4, 1/30];
coor = Tuples[{xcoor, ycoor}];
points = Partition[Flatten@Thread[{coor, Total /@ coor}], 3];
ListPointPlot3D[points]
POSTED BY: Okkes Dulgerci
Posted 7 years ago

This is exactly I was looking for thank you.

POSTED BY: Erdem Uguz
Posted 7 years ago

Is this what you are looking for?

coor = Tuples[{Range[1, 2, 1/2], Range[3, 4, 1/2]}];
ListPointPlot3D[ Partition[Thread[{coor, Total /@ coor}] // Flatten, 3]]
POSTED BY: Okkes Dulgerci
Posted 7 years ago

Okay maybe I did not pose the question well enough.

xcoor = Range[1, 2, 1/2];
ycoor = Range[3, 4, 1/2];
(x + y /. x -> xcoor) /. y -> ycoor

I want to be able to plot the matrix as data point with respect to xcoor and ycoor. Each point in the matrix has corresponding coordinates. I can't use the function directly (in this example x+y) . I have to use the matrix values.

POSTED BY: Erdem Uguz

You can't 3Dplot your list because each point has 4 coordinates. Something is wrong with your question.

POSTED BY: Ivan Siahlo
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