How to add error bars to a semilogy plot?
30 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
dpb
2017 年 2 月 14 日
編集済み: dpb
2017 年 2 月 14 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Errorbars についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!