I am very, very new to Mathematica (I downloaded it 1 hour ago). I have a set of 1000 rows, 4 columns data, in a CSV file: data

My first problem is that I don't know how to select the columns in the CSV file I want to plot.

My second problem is as follows: I have done another CSV file, that contains only columns 1, 2 and 3 of the attached data file. When I plot it, it looks like this:


I doesn't make sense to me. It looks like the adaptability is ignored: all the points above 0.1 seem not to exist.

Finally, I would like to add the 4th column of my data file in this graph. Like a color gradient perhaps. Is it possible to do so?

  • $\begingroup$ The reason it is ignoring a bunch of data points is because they have duplicated (x, y) values. For example, points 8, 9, and 10 are all (28, 0.0909091, 0.0909091). I'm not exactly sure how MMA resolves this issue of duplicates, but you can be certain it's throwing out a bunch of your data points. Also, to select columns you can use Part. The shorthand notation for Part is this: data[[All, 1 ;; 3]]. Assuming your data is called data, this selects all rows and columns 1 through 3. data[[10]] would show you all columns for data point 10, etc. $\endgroup$
    – MassDefect
    Apr 12, 2019 at 18:28

1 Answer 1


There are a few options for plotting 4D data. ListContourPlot3D, ListDensityPlot3D, ListSliceDensityPlot3D are a few that come to mind. I think a density plot would work best for your data, so this is what I did:

data = Import["~/Desktop/Downloads/WZN5hSTv.txt", "Data"];
  ColorFunction -> "TemperatureMap",
  OpacityFunction -> (# &),
  PlotLegends -> Automatic,
  PlotRange -> Full

And that yields:

List density plot of 4D data.

The grey bar to the left of the legend indicates the opacity level used for the data. You can change it using the OpacityFunction. The way my opacity function works is by scaling it directly with the value. The # is a placeholder, and the & symbol tells MMA to fill that placeholder with the argument that it normally sends to OpacityFunction. You can also erase that line and let MMA choose for you, or instead of having a function, you can just use OpacityFunction -> 1 and it will be opaque which would let you see the surface in greater detail.

  • 2
    $\begingroup$ ListDensityPlot3d is a great option. If you want to change the order of your columns to adjust which lines up with {x,y,z,intensity} , you can use something like this to reorder data (assuming that is your variable) data[[All, {2, 3, 1, 4}]] $\endgroup$
    – kickert
    Apr 12, 2019 at 19:38
  • $\begingroup$ Thanks a lot! I found this plot by browsing the documentation, just before reading your post. It is good to know. I have finally use another approach, as the visualization is not very straightforward. $\endgroup$
    – Jean Oudot
    Apr 13, 2019 at 14:07

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.