large errorbars on semilogx
7 ビュー (過去 30 日間)
古いコメントを表示
I am trying to plot mid vs columns. And I am getting either partial or very elongated errorbars. Please find the datafile and plot below. Will really appreciate a solutions to this issue. Thanks.
0 件のコメント
回答 (2 件)
Steven Lord
2024 年 3 月 18 日
What's the difference between the logarithm of 1 and the logarithm of 2?
format longg
x1 = log([1 2])
delta1 = diff(x1)
Now what's the difference between the logarithms of 11 and 12?
x2 = log([11 12])
delta2 = diff(x2)
How much larger is the difference between logarithms?
delta1/delta2
So an errorbar of length 1 will be drawn much longer (about 8 times as long) if it starts around x = 1 than if it starts around x = 11. What value would you have to use as the right endpoint for the x = 11 errorbar to make it appear as long as the errorbar of length 1 starting at x = 1?
x3right = exp(x2(1)+delta1)
semilogx([1 2 NaN 11 12 NaN 11 x3right], [1 1 1 2 2 2 3 3])
ylim([0 4])
The line at y = 1 looks to be about the same length as the one at y = 3.
A quick check on my monitor with a ruler shows that the line at y = 2 is about an eighth as long as the lines at y = 1 and y = 3.
2 件のコメント
Steven Lord
2024 年 3 月 19 日
Solution to what? To making the error bars longer?
Either don't use a log scale on the axes or change your data about how long the error bars should be. In my example, the approach involving x3right was an example of the latter. For an example of the former:
plot([1 2 NaN 11 12], [1 1 1 2 2])
ylim([0 3])
These lines are the same length on my screen.
Voss
2024 年 3 月 18 日
What you see is because of the log XScale:
- Partial errorbars: If the left endpoint of the errorbar would be <= 0, it is not rendered on log scale, because log of a number <= 0 is complex or -Inf.
- Elongated errorbars: also an effect of logarithmic x-scaling. For example, a unit-length segment takes up more space in the plot if it goes from 1 to 2 than it takes if it goes from 10 to 11 (that's just how logarithmic scales work).
semilogx([1 2],[1 1])
hold on
semilogx([10 11],[1 1])
xlim([0.1 100])
5 件のコメント
参考
カテゴリ
Help Center および File Exchange で Errorbars についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!