3

I want to visualize 4 vectors of scattered data with a surface plot. 3 vectors should be the coordinates. In addition the 4th vector should represent a surface color. My first approach was to plot this data (xk,yk,zk,ck) using

scatHand = scatter3(xk,yk,zk,'*');    
set(scatHand, 'CData', ck);   
caxis([min(ck), max(ck)])

As a result I get scattered points of different color. As these points lie on the surface of a hemisphere it ist possible to get colored faces instead of just points. I replace the scattered points by a surface using griddata to first build an approximation

xk2=sort(unique(xk));   
yk2=sort(unique(yk));   
[xxk, yyk]=meshgrid(xk2, yk2);   
zzk=griddata(xk,yk,zk,xxk,yyk,'cubic');  
cck=griddata(xk,yk,clr,xxk,yyk,'cubic');     
surf(xxk,yyk,zzk,cck);  
shading flat;

This is already nearly what I want except that the bottom of the hemisphere is ragged. Of course if I increase the interpolation point numbers it gets better but than the handling of the plot gets also slow. So I wonder if there is an easy way to force the interpolation function to do a clear break. In addition it seems that the ragged border is because the value of zzk gets 'NaN' outside the circle the hemisphere shares with the z=0-plane. Hemisphere surface built out of scattered data

The red points at the top are the first several entries of the original scattered data.

Matthias La
  • 275
  • 1
  • 13

1 Answers1

2

You can set the ZLim option to slice the plotted values within a certain range.

set(gca, 'Zlim', [min_value max_value])

enter image description here

marsei
  • 7,691
  • 3
  • 32
  • 41