# Matlab scatter hotmap [closed]

I have two columns of data, x(angle) and y(distance), they are my experiment results(figure 1). How can I use these results to make a ‘hotmap diagram’ by matlab? The z axis is the density value of xy dots in the 2D coordinate department, like below figure2. Thank you!  You basically need to plot the scatter map with varying colors for each point

scatter(x, y, [], c);


The main difficulty is to calculatec so that it’s proportional to the density.

To do so you can divide the map into a grid of a certain resolution, say [res_x, res_y]. Then count for each grid cell how many points are there. This count is an approximation of the density at that grid cell. Finally you can assign to all points within this grid cell the c value equal this count.

Probably you also need to normalize c to [0, 1]

• Thank you for your help, I can understand your answer, but I don’t know which function should I choice to calculate the density? – user239932 Nov 15 '17 at 4:17
• That's already in the answer: use the count. – Pikalek Nov 16 '17 at 14:31