1
$\begingroup$

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! enter image description here enter image description here

$\endgroup$
1
$\begingroup$

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]

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

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