## Plot x y and time

on 16 Jan 2013

### Doug Hull (view profile)

Hi,

I am using scripts written by someone else a long time ago (who has long since gone) and I'm having trouble getting them to do something which is probably quite simple.

I have data from some tracking software and I'm trying to plot the x and y coordinates, as you would do normally but I want to show where the object spent the most time in the form of a pcolor map (so red will signify lots of time spent in an area etc).

I have a matrix (4 x ~30000), rows 1 and 2 contain the x and y coordinates and row 4 contains time in ms (at a 20ms sampling rate I believe).

I am sure I will need to bin the data somehow but I'm not sure how to do this...

Ultimately I want to do the same with velocity (a pcolor map with red signifying 'high speed') but I thought I would tackle this problem first.

Thank you very much for any help,

Rod.

## Products

No products are associated with this question.

### Doug Hull (view profile)

on 16 Jan 2013
Edited by Doug Hull

### Doug Hull (view profile)

on 16 Jan 2013

This is a 2-d histogram problem.

http://www.mathworks.com/matlabcentral/fileexchange/29709-function-to-make-a-2d-histogram

Here is a link to a MATLAB file Exchange file that should calculate a 2-d histogram for you.

This video might be good for you too. http://blogs.mathworks.com/videos/2010/01/22/advanced-making-a-2d-or-3d-histogram-to-visualize-data-density/

Doug

Right Grievous

### Right Grievous (view profile)

on 16 Jan 2013

Hi Doug and thanks for the reply!

I had a look at your second link and tried out the code there, it does exactly what I want, which is great and really smart (I am guessing that it is plotting x and y coordinates into bins, in my case these are coded to a specific timebase which means that this also plots time?).

In any case I was wondering if it is possible to smooth the plot more? I want to produce a pcolor plot as we use this for similar purposes but we apply gaussian smoothing to these so they obviously look a lot more pleasing to the eye... is it possible to incorporate a smoothing filter into your piece of script?

Thanks,

Rod.

Image Analyst

### Image Analyst (view profile)

on 16 Jan 2013

With few data points, it obviously will look quantized. The best option is to just collect some more data. A less desirable option is to blur your 2D histogram as if it were an image. For example

```blurred2DHist = conv2(original2DHist, ones(5)/5^2, 'same');
imshow(blurred2DHist);
colormap(hot);
colorbar;
```

#### Join the 15-year community celebration.

Play games and win prizes!

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi