3

x1 and y1 are two array of same length scatter (x1,y1); gives the scatterplot of the datas I have

Since there is a highly dense area and low density region in my graph. I would want to have a color Heatmap of the scatterplot.

Is it possible in Matlab.If possible than How.

Thanks in advance

user2546342
  • 61
  • 2
  • 6
  • OK so here is exactly your question (but in Python) http://stackoverflow.com/questions/6652671/efficient-method-of-calculating-density-of-irregularly-spaced-points however the complication here is the algorithm, so you should be able to understand that from the python code. Once you do, try port to Matlab and let us know where you get stuck – Dan Jul 10 '13 at 08:59

1 Answers1

1

You can control the colour of each point like so:

scatter(x1, y1, [], C)

where C is the same size as your x1 and y1 matrices. Now if you describe the rules of how you want this heatmap colour modulation to happen, we can help you construct C from x1 and y1...

Dan
  • 45,079
  • 17
  • 88
  • 157
  • @user2546342 For finding the density I suggest you create a grid that ranges from `min(x1)` to `max(x1)` along one dimension and then the same for `y1` along the other. Then for each point, increment the grid element that that point falls in. Afterwards apply something like a Guassian blur (`conv2` will help you there). You must experiment with the right filter for the blurring and the right grid resolution for your dataset. Check out the Python example I posted, it's very very similar – Dan Jul 10 '13 at 09:01