- if all of the y coordinates are negative, a warning is given and plotting proceeds as if the values were positive; otherwise
- no line is drawn to any vertex that has a negative y coordinate
- no face is drawn for any surface or patch area that has a negative y coordinate
Vertical error bars disappear on logy plot
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Karellen
le 9 Mar 2021
Réponse apportée : Walter Roberson
le 9 Mar 2021
I made a scatter plot then added error bars:
err = errorbar(statsx, avgs, error, 'LineWidth', 2, 'CapSize', 12);
err.LineStyle = 'none';
err.Color = 'b';
I then set the y axis to log:
set(gca, 'YScale', 'log')
... and about half of the negative error bars disappear. The bars which disappear are consistent whenever I re-run the script. When I set the axis back to linear, all bars re-appear.
What could be happening?
0 commentaires
Réponse acceptée
Walter Roberson
le 9 Mar 2021
When you use Yscale log, then:
bar() plots are patch() objects, so if a bar has any negative y coordinates, that bar will not be drawn, not even if you ylim a positive lower bound. MATLAB will not attempt to find the intersection of the face and the ylim / xlim and draw only that part: the entire face will be omitted, same as if it had a coordinate that was infinite or nan.
Error bars themselves might have the limits drawn as line objects, so you can end up with the situation where an reference line is drawn (because its ends are positive) for a face that is not drawn (because it has a negative y coordinate somewhere)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Object Properties 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!