Error bars not working on loglog plot

7 ビュー (過去 30 日間)
Tim Keegan
Tim Keegan 2022 年 3 月 23 日
コメント済み: Tim Keegan 2022 年 3 月 23 日
I am trying to add error bars to a loglog plot and matlab and nothing I try is working. I've gone about it in many different ways including plotting using plot(x,y) then changing the scale to log, using loglog(x,y), and trying errorbarlogx. I dont know why the error is only above the data point for the later points (it shouldnt be). This is my code that made the above graph.
loglog(distance,radiation)
log_distance=log(distance);
log_radiation=log(radiation);
fit=polyfit(log_distance,log_radiation,1)
m=fit(1)
b=fit(2)
z=polyval(fit,log(distance))
hold on;
errorbar(distance,exp(z),combined_error)
What am I doing wong?
  4 件のコメント
Tim Keegan
Tim Keegan 2022 年 3 月 23 日
I get warning:negative data ignored every time I run it
Adam Danz
Adam Danz 2022 年 3 月 23 日
See Star Strider's answer.
You may also want to review some log properties

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

採用された回答

Star Strider
Star Strider 2022 年 3 月 23 日
You are likely not doing anything wrong. The lower error bars are most likely negative, and values less than or equal to zero do not plot on a logarithmic axis scale. (Those logarithms are defined, however they are complex, and purely imaginary values do not plot in MATLAB.)
  5 件のコメント
Adam Danz
Adam Danz 2022 年 3 月 23 日
> Is there any way for me to get the error bars to look normal on the loglog axis?
see this related answer
Tim Keegan
Tim Keegan 2022 年 3 月 23 日
thank you @Adam Danz that worked.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by