How to plot XYZ data, so that the Z-components are plotted as large 'pixel' and have a color corresponding to their value.
조회 수: 51 (최근 30일)
이전 댓글 표시
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);
댓글 수: 0
답변 (1개)
dpb
2015년 11월 23일
Try
scatter(x,y,25,z,'filled')
Salt to suit on colormap, marker size, etc., etc., etc., ...
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!