# Plotting points of matrix

I have a matrix with 'n' rows and 3 columns where the first two columns are the X and Y values and the third column is f(x,y). All values are numeric. I want to do a 2D-plot where third column gives the colour of the points. How to do it? I want only points and want to plot it like a Temperature map.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Commented Jul 10, 2021 at 21:54

With a few bells and whistles

Clear["Global*"]

SeedRandom[1];
f[{x_, y_}] := {x, y} . {1, 1}^2
data = Append[#, f[#]] & /@ RandomReal[1, {10, 2}];

{zmin, zmax} = MinMax[data[[All, 3]]]

(* {0.3071, 1.80233} *)

Legended[
Graphics[{
PointSize[Large],
{ColorData["TemperatureMap"][
Rescale[#[[3]], {zmin, zmax}]],
Tooltip[Point[Most@#], #]} & /@ data},
Frame -> True,
Background -> Black,
FrameStyle -> White,
FrameLabel -> (Style[#, 14, Bold] & /@ {x, y}),
ImageMargins -> 20],
BarLegend[{"TemperatureMap", {zmin, zmax}},
LegendLabel -> Style[z, 14, Bold]]]


• Thanks! This helps a lot. Commented Jul 8, 2021 at 14:47
(** some fake data - a matrix of:
{{x1,y1,f[x1,y1]},
{x2,y2,f[x2,y2]},
...,
{xn,yn,f[xn,yn]}} **)

SeedRandom[1];
f[{x_, y_}] := {x, y} . {1, 1}^2
data = Append[#, f[#]] & /@ RandomReal[1, {10, 2}];

(* get a TemperatureMap and scale f[x,y] into [0,1] *)
cf = ColorData["TemperatureMap"];
colsScaled = cf /@ Rescale[data[[All, 3]]];

Graphics[{PointSize[Large],
Point[data[[All, ;; 2]], VertexColors -> colsScaled]
}, Axes -> True, Background -> Black, AxesStyle -> White
]
`

• Black background is because TemperatureMap doesn't show up so well on white - feel free to experiment. Commented Jul 7, 2021 at 13:31
• This Works, Thanks! I forgot the Graphics command. Commented Jul 7, 2021 at 15:58