Slice NaNs showing strange behaviour
6 views (last 30 days)
Show older comments
I have a 701 x 5 x 29 3D array (named V), produced from meshgrid and interp2. The data is good, i've checked through each layer and everything is in order (no data missing, monotonically spaced, and nans used for no data), the problem arises when I plot the data in slice, where the use of NaNs cuts the end of the data off (circled, bottom image).
If I replace the NaN's with zeros the data shows up, but then the issue is that the white isn't transparent (see attached). Here's the applicable code (removed axis labels etc)
V(isnan(V)) = 0; %uncomment and full lines are plotted
V_p = permute(V,[3 2 1]);
[XI3d,YI3d,ZI3d] = meshgrid(1:size(V_p,2),YI,XI); % all working
figure
slice(XI3d,YI3d,ZI3d,V_p, 1:5,0,0);
shading flat
set(gca(),'Zdir','reverse');
set(gca(),'xdir','reverse');
xlim([1 5]);
caxis([140 230]);
colormap([1,1,1;jet(64)]);
view(73,66)
So two part question: Is this just another Matlab quirk which you have to work around or is there a simple way to stop it? Is there an easy way to make one color within a color map transparent instead of the whole thing.
Cheers J
6 Comments
Answers (0)
See Also
Categories
Find more on 3-D Scene Control in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!