How do I get working y-axis errorbars using a log scale?
132 次查看(过去 30 天)
显示 更早的评论
I'm trying to plot data on a semilog plot (y-axis: log, x-axis: linear), but the errorbars are seriously screwed up.
All I'm doing is loading my data and entering:
figure
errorbar(hp_v3,hp_D0,hp_D0_,'ok')
set(gca,'YScale','log')
where hp_D0_ is the vector of uncertainty values for vector hp_D0. This results in the plot attached as an image, which obviously isn't working.
I've also tried errrobarlogy, which produces literally the same plot. Any ideas?
0 个评论
回答(1 个)
Mike Garrity
2015-9-8
That looks like what happens if the bottom of the errorbar is negative.
What do you get if you do this:
h = errorbar(hp_v3,hp_D0,hp_D0_,'ok');
h.YData - h.LData
Are the resulting values negative?
If so, what's happening is that the log transform of the negative value results in a complex value which it can't transform to a point on the screen.
Here's an attempt to recreate your data:
rng default
hp_v3 = 986:1002
hp_D0 = 1e-4*rand(1,17);
hp_D0_ = 1e-4*randn(1,17);
h = errorbar(hp_v3,hp_D0,hp_D0_,'ok')
set(gca,'YScale','log');
We can tweak the LData to stay positive like this:
ylim manual
h.LData = h.YData - max(eps,h.YData-h.LData);
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!