# ListPointPlot3D plotting 4 dimensions

I have a data set with four columns, i.e. dimensions, all are numerical. The last attribute is either 0 or 1. So I want to plot the data in the following way: the first three entries are the coordinates and the determines the color (0:Red, 1: Green). I can plot this using Graphics3D like:

Example data:

list = {{1, 29., 2, 1}, {1, 0.9167, 1, 1}, {1, 2., 2, 0}, {1, 30., 1,0}, {1, 25., 2, 0}}


then:

ClearAll[plotPoint];
plotPoint[list_List] := Module[{c, a, g, s},
{c, a, g, s} = list;
If[s == 1,
Graphics3D[{PointSize[Small], Green, Point[{c, a, g}]}],
Graphics3D[{PointSize[Small], Red, Point[{c, a, g}]}]
]
]


then

Show[plotPoint /@ list]


delivers an output. What I now tried to achieve is to do this job with ListPointPlot3D to get axes and so on. But here I can only deliver a ColorFunction which takes three arguments (the coordinates) and I could not manage to get my fourth attribute (last components in data set) in there to get the coloring. Is there any way to do this?

list2 = Style[{#, #2, #3}, #4 /. {0 -> Red, 1 -> Green}] & @@@ list;
ListPointPlot3D[list2, BaseStyle -> PointSize[Large]]


Alternatively,

ListPointPlot3D[List /@ list[[All, ;; 3]],
PlotStyle -> (list[[All, 4]] /. {0 -> Red, 1 -> Green}),
BaseStyle -> PointSize[Large]]


same picture

• Thanks a lot. O.K. when you know it - it is simple, but if not.... One of the solutions where I ask myself why I haven't seen it. Commented Oct 28, 2018 at 14:27

Another alternative:

Graphics3D[
{PointSize[Large],
Point[list[[All, ;; 3]],
VertexColors -> (Blend[{Red, Green}, #] & /@ list[[All, 4]])]
},
PlotRange -> Automatic,
Options[ListPointPlot3D]]


Another way to get the colors:

VertexColors -> IdentityMatrix[3][[1 + list[[All, 4]]]]

• Thank you, cool application for Blend, too. Commented Oct 29, 2018 at 13:29