How do I get working y-axis errorbars using a log scale?
Mostrar comentarios más antiguos

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?
Respuestas (1)
Mike Garrity
el 8 de Sept. de 2015
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);

Categorías
Más información sobre Errorbars en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!