Basically I have a set of 3D points, such as {3,4,3} or {4,1,4}. Instead of plotting the points in a 3D space, I want to plot the x,y coordinates of the points on the 2D plane and use the z coordinate to define a color for that point. So the color will be different depending on the z coordinate. I've tried a lot of things and haven't had any luck. Any help would be appreciated.


2 Answers 2



data = RandomInteger[10, {10, 3}];
sdata = Style[{#, #2}, PointSize[.05], 
     ColorData[{"Rainbow", Through@{Min, Max}@data[[All, -1]]}][#3]] & @@@ data;

ListPlot[sdata, PlotRangePadding -> 3]

enter image description here


ListPlot[List /@ data[[All, ;; 2]], PlotRangePadding -> 3, 
 BaseStyle -> PointSize[.05], 
 PlotStyle -> (ColorData[{"Rainbow", 
      Through@{Min, Max}@data[[All, -1]]}] /@ data[[All, -1]])]
(* same picture as above *)


sdata2 = Style[Labeled[{#, #2, 1}, #3, Center],
      ColorData[{"Rainbow", Through@{Min, Max}@data[[All, -1]]}][#3]]] & @@@ data;


enter image description here


One way is just to build it up from primitives. Here is some data:

data = RandomReal[{1, 10}, {10, 3}];

rescale the z values:

data[[All, 3]] = Rescale[data[[All, 3]], {1, 10}];

or rescale over min and max of the z values etc -- up to you. Then plot:

  MapThread[{Hue[#3], Point[{#1, #2}]} &, Transpose[data]]},
 AspectRatio -> 1/GoldenRatio,
 Frame -> True]

enter image description here


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.