Scatter not ignoring NaN in image
Mostra commenti meno recenti
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 Commenti
Guillaume
il 1 Ago 2017
It would be useful to know which of the inputs of scatter are NaN (The 4th input?) and exactly how you are invoking scatter.
The following works fine for me:
[x, y] = meshgrid(1:10);
c = 1:100;
c([10:10:40, 19, 29]) = nan;
scatter(x(:), y(:), [], c(:), 'filled');
The NaNs are not plotted (R2017a)
H ZETT M
il 1 Ago 2017
H ZETT M
il 1 Ago 2017
Risposta accettata
Più risposte (1)
Muhammad RSMY
il 23 Set 2017
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 Commento
Guillaume
il 23 Set 2017
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));
Categorie
Scopri di più su Discrete Data Plots in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!