Slice NaNs showing strange behaviour
이전 댓글 표시
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
What exactly is the problem? The correct and documented behavior is that NaN's are ignored in plotting. Of course if you replace these NaN's with zeros (or some other finite value) then these will be plotted and colored depending on the current colormap .
It is not clear what you expect to happen, you only mention "the problem arises", but do not state what this problem is. Can you please clarify exactly what part of the plot is not to your liking.
It might be related to interpolating data containing NaN's: you might like to check the data that you actually plotting to see how many and where the NaN's are.
John Atkinson
2014년 12월 3일
편집: John Atkinson
2014년 12월 3일
Stephen23
2014년 12월 3일
Is this the only part of the data containing NaN's, or are they present throughout the data set?
John Atkinson
2014년 12월 3일
John Atkinson
2014년 12월 3일
답변 (0개)
카테고리
도움말 센터 및 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!