enter image description hereI am new to Mathematica. I learned how to join 2 lists to make (x,y) type of representation using Transpose@{X,Y}. Now my problem is that I have to make a table of 3 variables. I have one set of data with 63 points, another one with 64, and I have third one which is a huge table recording third type of data at 64 rows and 63 columns, related to the first two types. Now I want to make a plot (ListContourPlot) where X and Y will create a surface from first 2 data (as last data doesn't know what are X and Y), and on Z axis will be related to the 3rd dataset values at each of the (x,y) values. Sorry for ambiguous explanation. Thank you in advance.

  • $\begingroup$ Code and data are much less ambiguous than natural langauge text. It would help if you posted a sample of your data. Please don't post the entire 64x63 matrix. Pare down your lists to a maximum of 5 (or whatever is both readable and sufficiently illustrative) in any dimension. $\endgroup$
    – lericr
    Commented May 11, 2022 at 14:30
  • $\begingroup$ I added a picture of what I would like to achieve. So that 64x63 matrix (in this case 5x4) is z-points. I have a separate list of x and y points (as shown on example in the picture). Each of these 3 sets is saved in separate files that I imported into Mathematica. And then I am trying to create a table which looks like the picture. $\endgroup$
    – Saitama
    Commented May 11, 2022 at 14:48
  • $\begingroup$ Okay, I see a matrix of data now. What we need next is how to find the (x,y) values. Presumably this is what your other lists are, but I'd like to see that to confirm and understand. $\endgroup$
    – lericr
    Commented May 11, 2022 at 14:50
  • $\begingroup$ This will also be much easier if you add the data as copy-paste-able code. Go through the introductory tour to find out how to do that on this site. $\endgroup$
    – lericr
    Commented May 11, 2022 at 14:51
  • $\begingroup$ Have you imported the data successfully? If not, that's a separate step that we can help with, but if you've imported the data into Mathematica, that's the data that I want to see. $\endgroup$
    – lericr
    Commented May 11, 2022 at 15:13

1 Answer 1


Let's assume that the x-coordinates are in a list called xs. Similarly for a list called ys. Let's say data is len(xs) by len(ys) and holds the z values. We need to get some data in the right shape for ListContourPlot. We can pair up the xs and ys like this:

Outer[List, xs, ys]

To get the data in a compatible shape for Join (there are other options, but this works), we need to add a layer of List:

Map[List, data, {-1}]

Now we can join them:

plotData = Join[Outer[List, xs, ys], Map[List, data, {-1}], 3]

Now we want just a list of points in 3D space:

Flatten[plotData, 1]

This can be fed into ListContourPlot:

ListContourPlot[Flatten[plotData, 1]]

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.