Heat map with many discrete data points
10 views (last 30 days)
Show older comments
Hey everyone, I have seen a couple of questions and answers along this topic but none answer exactly what I need. I am producing a simulation, which outputs the X/Y/Z coordinates of the origin of photons and how many photons came from that point. So for example, one recorded event may have the following x1, y1, z1 coordinate and 23 photons were measured from this point.
I need to create a heat map of these points, with views in multiple planes (so looking down the Z axis, or looking down the X/Y axis etc).
The problem i think is that my coordinates are discrete, and I need to 'bin' my coordinates into a sort of '3D histogram' to produce the colour map I want. The two methods below produce smeared data in dark zones, and missing data points too. In some cases my z coordinates are very close together (around 1/2mm apart down to 3 decimal places) and the corresponding x/y data range is large (between -70 and 70 mm, again with 3 d.p). The problem with this is I can't seem to make a colour map which has equal length and height (i.e. 140x140mm), I get one which is 2/140mm and then expanded to fit the window, if that makes sense.
Here is what I've tried so far: (where x/y are my coordinates and h is the photon hit number)
y2=round(y-min(y)+1);
x2=round(x-min(x)+1);
figure;plot(x2,y2,'o')
%fill array
A=[];
for k=1:length(y),
A(x2(k),y2(k))=h(k);
end
figure
imagesc(A);
colormap(jet);
The problem with this technique is it rounds my data points to whole numbers, not great as I need m.m. precision. I've also tried this: (x/y again coordinates and h is hit number)
x2min = min(x);
x2max = max(x);
y2min = min(y);
y2max = max(y);
[X,Y] = meshgrid(linspace(x2min,x2max,500),linspace(y2min,y2max,500));
V = griddata(x,y,h,X,Y);
J = imagesc(V);
colormap jet;
Didn't work great on some graphs as it smears together values (noticed in dark spots with no hits it has given them values).
My knowledge of MatLab is fairly limited and I feel what I need to do is somewhat advanced so I'm very sorry if any of that is incoherent! Any help would be greatly appreciated! Sorry for the long question, Thanks!
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!