- Use NaN and Inf values to create breaks in the lines. For example, this code plots the first two elements, skips the third element, and draws another line using the last two elements:plot([1,2,NaN,4,5])
Waterfall plot not showing correctly
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I think this is an undesirable feature of the waterfall plot function and I'm posting it here so that others don't spend as long as I did trying to figure out why your plot doesn't look right.
Here is an example of a correcly rendered waterfall plot:
figure(1)
[X,Y] = meshgrid(-5:.5:5);
Z = Y.*sin(X) - X.*cos(Y);
p = waterfall(X,Y,Z)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/658000/image.png)
If you happen to have nan values in your data the plot does not raise an error but the white 'area-fill' of each plot line dissappears.
figure(2)
Z(:,5) = nan;
p2 = waterfall(X,Y,Z)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/658005/image.png)
I couldn't find any mention of this in the documentation, and when you don't know that nan values are the cause of this, it's very hard to diagnose. Especially if your data set is large or the nan values are in the first or last column and it's not so obvious to see that there is a gap in the data as it is in these simple examples.
3 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!