Scatter not ignoring NaN in image
조회 수: 10 (최근 30일)
이전 댓글 표시
Hey everyone, I need your help for a short moment. I used "scatter" to plot the following image.
I am quite happy with the image, but there is one problem. The data that I circled are NaN, but they simply get displayed as the lowest value by the scatter function. I tried to change the colorbar into ignoring NaN or making them invisible, but this did not work. Do you know a way to make the NaN values invisible (or simply remove them ?). The matrices I used to create this image are 11x11.
댓글 수: 3
채택된 답변
Guillaume
2017년 8월 1일
As mentioned, the NaNs are correctly ignored in R2017a. I don't have R2015b installed anymore to test. You can easily work around the issue by removing the NaNs yourself:
nonans = ~isnan(distance);
scatter(alpha(nonans), beta(nonans), 500, distance(nonans), 'filled')
댓글 수: 0
추가 답변 (1개)
Muhammad RSMY
2017년 9월 23일
Data(isnan(Data))= 0;
idx = find(Data);
[X, Y] = ind2sub(size(Data), idx);
pointsize = 40;
scatter(X(:), Y(:), , pointsize, Data(idx),'square','filled');
colormap jet
colorbar
댓글 수: 1
Guillaume
2017년 9월 23일
Not sure why you're answering this 2 months after the question has been asked, particularly without any explanation.
Data(isnan(Data))= 0;
idx = find(Data);
[X, Y] = ind2sub(size(Data), idx);
Well, that's a very convoluted way of simply doing
[row, col] = find(~isnan(Data));
참고 항목
카테고리
Help Center 및 File Exchange에서 Purple에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!