Surf and NaN plotting bug
Mostra commenti meno recenti
Hello,
I have some data I am trying to plot with the surf command. The data has many NaN entries with small islands/peninsulas of good data. The NaN entries represent time/locations where no data is available. When I plot the data using surf(), I lose many of the finer feature - thin islands disappear. If I replace all of the NaN entries with a scalar (0), the islands reappear. Is there a workaround to plot all of the good data and have the NaN remain as blanks?
Matlab version is 2017a
Risposte (2)
James Noll
il 10 Ott 2019
Modificato: James Noll
il 10 Ott 2019
1 Commento
Walter Roberson
il 10 Ott 2019
pcolor() uses the x and y you give, and all zeros as the z, and uses the data you give as the cdata information in a call to surface() . Which is to say, it is surf() with x, y, 0, b . If you look at something like
pcolor(randi(10,5,7))
you will see that it draws (5-1) by (7-1) faces. It is doing interpolation.
Walter Roberson
il 10 Ott 2019
Modificato: Walter Roberson
il 10 Ott 2019
0 voti
surf() and pcolor() determine the color of faces by bilinear interpolation of the four corners. Any single nan is at the corner of four different faces, so any given nan "poisons" four faces making them empty because the calculation comes out nan. It is easy for thin islands to disappear.
You should look more carefully at the CData and AlphaData properties
However when you make your decisions you are probably going to encounter the same basic issue that surf faces do not reflect individual locations, which is probably what you want.
Depending on your needs, warp() might be more useful to you. If not, then go for patch() as it offers more flexibility as to how face color is derived.
Categorie
Scopri di più su Lighting, Transparency, and Shading in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
