Scatter not ignoring NaN in image
65 views (last 30 days)
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.
Guillaume on 1 Aug 2017
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')
More Answers (1)
Muhammad RSMY on 23 Sep 2017
idx = find(Data);
[X, Y] = ind2sub(size(Data), idx);
pointsize = 40;
scatter(X(:), Y(:), , pointsize, Data(idx),'square','filled');