Error bars drawn asymmetrically in errorbar()

4 ビュー (過去 30 日間)
Anshuman Pal
Anshuman Pal 2020 年 7 月 8 日
コメント済み: Anshuman Pal 2020 年 7 月 9 日
Hello,
I am using the errorbar() function, and for some reason, the error bars are being drawn asymmetrically around the data points. In other words, the data point is not at the centre of the error bar. Can someone please explain why? Am I missing something?
The basic code:
x = w.^2 .* t ; y = lambdaFinal; yerr = deltaLambda;
errorbar(x, y, yerr, 'o', 'MarkerEdgeColor','red','MarkerFaceColor','red')
I have highlighted some of the egregious examples in the attached picture.
  1 件のコメント
madhan ravi
madhan ravi 2020 年 7 月 8 日
Mind sharing the data?

サインインしてコメントする。

採用された回答

dpb
dpb 2020 年 7 月 8 日
編集済み: dpb 2020 年 7 月 9 日
Yeah, the y-axis scale is logarithmic so the positive and negative differences are scaled differently depending where on the log scale the point is. Those right around a decade change will be most noticeable as the change in scale is most pronounced.
The two particular points at the middle are such that the error magnitude is greater than or equal to the value so the lower error bar location is zero or negative. Can't plot nonpositive numbers on a log scale; errorbar silently just doesn't plot those whiskers. Probably should give a warning message; plot will, but errorbar doesn't.
hAx=gca;
hAx.YScale='linear';
and a revelation will occur! :)
  1 件のコメント
Anshuman Pal
Anshuman Pal 2020 年 7 月 9 日
Perfect! Thanks a lot, the effect of logscale on error bars had never occurred to me.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by