# How to color-code a 3D point plot

I am doing a Finite Difference Method for 3D heat diffusion, so I need my ListPointPlot3D to be color coded on a range from deep red to deep blue depending on the temperature of the point.

My instinct is that I should have a fourth dimension to my list of points describing the temperature at that point, e.g {1,1,1,40} would describe a temperature of 40 at the first point in my partition, and so on. Is there a plotting option that lets me range the color of a point based on this 4th parameter?

If not, do you see any other way I can do this in Mathematica? I have tried ColorFunction, but I don't want my temperature to depend on the spatial dimensions x,y,z, I want it to depend on a fourth dimension "w" where the temperatures exist.

Many thanks

• ColorFunction -> Function[{x,y,z}, Hue[z]] – David G. Stork Nov 7 '15 at 1:20

SeedRandom[1];

(data = Append @@@
({RandomReal[{0, 1}, {10, 3}],
RandomReal[{0, 100}, 10]} //
Transpose)) // Grid


n = 1;
Graphics3D[{AbsolutePointSize[6],
{Blend[{Blue, Red}, Rescale[Last[#], {0, 100}]],
Point[Most[#]], Text[n++, Most[#], {2, 2}]} & /@ data}]


• I'd probably use MapIndexed[] with Text[] for the labeling myself. – J. M.'s discontentment Nov 7 '15 at 1:47
• Thanks Bob, couldn't be more to the point! – Mike Nov 7 '15 at 1:53