How to plot XYZ data, so that the Z-components are plotted as large 'pixel' and have a color corresponding to their value.

47 views (last 30 days)
I have XYZ data where X and Y are arranged in a grid like order. I want to plot the Z values, so that each position is represented by a large 'pixel' that has a color that corresponds to the Z value.
In the attached picture you can see something similar to what I want that I achived by creating a meshgrid that has an offset to the XY positions by 0.5*gridsize and using griddata to interpolate the values. Using surf and view(2), I can plot something similar to what I want, but it is actually an interpolation of the meshgrid positions and thus not exactly what my data shows. Also I want the 'pixels' only where I actually have a measurement. I could use 'linear' method in griddata instead of 'v4' but then I would not have measurements at the outermost points. The small red dots are the meshgrid positions, the white x the actual XY positions and the surface the plotted output of surf.
The code to generate the figure:
[xg,yg] = meshgrid((min(x)-0.5*delta_x):delta_x:(max(x)+0.5*delta_x),...
(min(y)-0.5*delta_y):delta_y:(max(y)+0.5*delta_y));
v = griddata(x,y,z,xg,yg,'v4')
figure(1); hold on;
plot3(x,y,z, 'wx')
surf(x,y,v)
axis equal;
view(2);

Answers (1)

dpb
dpb on 23 Nov 2015
Try
scatter(x,y,25,z,'filled')
Salt to suit on colormap, marker size, etc., etc., etc., ...

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!