# 3D Plot using data from a .dat file

Suppose I have a .dat file, that I could easily manage to import it and it read as below

data = {{0., 1.5, 32., 4.}, {0.01, 13.339967195548438,
43.07461560857787, 6.505586235757622}, {0.02,
26.576707615610186, 62.27984871710982,
14.52957307602648}, {0.03, 43.92146166445253, 88.22533168346912,
33.35986308123866}, {999.97, 4.852152291519739,
20.914352068678742, 78.65196295800204}, {999.98,
11.498870411172586, 23.281707241849393,
81.49717171318073}, {999.99, 17.163630489595015,
23.943758603766856, 85.08665301847587}, {1000.,
21.44200492399224, 22.39480828216125, 88.75135651276551}}


Now, I need to plot a 3D graph using data available in column-2 vs column-3 vs column-4. How do I do that?

• ListLinePlot3D[data[[All, 2 ;; 4]]] ?
– Syed
Commented Apr 23, 2022 at 10:49
• For v13, you have commands available (such as ListPointPlot3D, ListLinePlot3D, ListSurfacePlot3D) for which you can look up information in the docs.
– Syed
Commented Apr 23, 2022 at 10:55
• If you have an array of 4 data points such as myData= {{a,b,c,d},{d,e,f,g},...{p,q,r,s}} and you want to plot the fourth element as a function of the second and third, then extract second, third, and fourth and use ListPlot3D[myData[[All,2;;]]]
– josh
Commented Apr 23, 2022 at 11:12
• data[[All,2;;4]] // Point // Graphics3D ? Commented Apr 23, 2022 at 16:04
• I need to Plot only the last 100 data from the .dat file. How do I choose that? Commented Apr 24, 2022 at 1:55

Let's take the toy-model set you provided and assume that you want to plot the last three.

The way to pick them

lastthree = data[[6 ;;]]


One way to plot them is using ListPointPlot3D

ListPointPlot3D[lastthree, PlotRange -> All,
LabelingFunction -> Callout, ColorFunction -> "Rainbow"]


And a couple of more based on ListPlot3D and ListLinePlot3D

ListPlot3D[lastthree, PlotRange -> All]
ListLinePlot3D[lastthree, PlotRange -> All]


Have fun!

• I am using Mathematica 12.0. And ListLinePlot3D seems to be absent there. How do I join the points if I am using ListPointPlot3D? Commented Apr 25, 2022 at 4:33
• @user84456 I have been trying to find an easy way to do it but I have not been able to do so. Sorry!
– bmf
Commented Apr 25, 2022 at 5:53