2
$\begingroup$

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.

$\endgroup$
5
$\begingroup$

ListPlot

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

Or

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 *)

BubbleChart

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

BubbleChart[sdata2]

enter image description here

$\endgroup$
3
$\begingroup$

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

SeedRandom[123];
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:

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

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.