Providing a color function for ListPointPlot3D
Using VertexColors
is efficient if there are many points.
SeedRandom[1];
pts = RandomReal[1, {100, 3}];
Post-process ListPointPlot3D
:
ListPointPlot3D[pts, PlotStyle -> PointSize[Large]] /.
Point[pp_] :>
Point[pp, VertexColors -> (Blend[{Yellow, Brown}, #] & /@ Rescale@Range@Length[pp])]
Or directly with Graphics3D
:
Graphics3D[{PointSize[Large],
Point[pts, VertexColors -> (Blend[{Yellow, Brown}, #] & /@ Rescale@Range@Length[pts])]},
BoxRatios -> {1, 1, 0.4`}, Axes -> True
]
In both cases I get indistinguishable graphics:
Doing this with ListPointPlot3D is not very straightforward, but do look at the answer by m_goldberg.
However, ListPointPlot3D
is trivial to re-implement in terms of graphics primitives. Here's one way to colour based on index:
pts = RandomReal[1, {10, 3}];
Graphics3D[
{PointSize[Large],
MapIndexed[{Blend[{Yellow, Brown}, First[#2]/Length[pts]], Point[#1]} &, pts]}
]
The second argument of Blend
must be a number between 0 and 1, so we needed to divide the index by the total number of points.
In V10, with the new association objects, it is easy to implement what you want with ListPointPlot3D
What is needed is a hash map (which is my mental image of an association) that maps your list of points into index values for Blend
. This can be built with AssociationThread
. Consider
pts = RandomInteger[99, {100, 3}];
indxs = AssociationThread[pts, Range @ Length @ pts/Length @ pts];
ListPointPlot3D[pts,
PlotStyle -> {PointSize[Large]},
ColorFunctionScaling -> False,
ColorFunction -> (Blend[{Yellow, Brown}, indxs[{##}]] &)]