How to add error bars to a semilogy plot?
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have three arrays: Array A has my x values to be plotted logarithmically Array B has my y values to be plotted linearly Array C has the values for error bars for the point (A,B).
Right now I have semilogx(A,B,'o') which gives me the plotted points. How do I add the error bars?
0 commentaires
Réponses (1)
dpb
le 14 Fév 2017
Modifié(e) : dpb
le 14 Fév 2017
hAx=axes; % new axes; save handle
errorbar(A,B,C,'o') % plot as errorbar
hAx.XScale='log' % turn to semilogx form
xlim([minDecade maxDecade]) % fixup x limits for visibility in log coordinates
ADDENDUM
Actually, some further playing around show that one can rearrange the above sequence a little as
hAx=axes;
hAx.XScale='log'
xlim([minDecade maxDecade])
hold all
errorbar(A,B,C,'o')
and errorbar will plot into the semilogx axes. This might just seem a little more direct when compute the xlim ranges from the data in A first and set those instead of the autoranging that occurred in the other sequence.
Or, with a little more repetition, it would be possible to let semilogx first do its autorange trick, retrieve those limits and then replot with errorbar after clearing the line (save the handle) and using hold to keep the updated axes. As virtually always w/ HG, there's a "veritable plethora" of nuances in the details to achieve a desired end result and rarely is any one way clearly "best".
0 commentaires
Voir également
Catégories
En savoir plus sur Errorbars 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!