Using errorbar() with semilogy() in MATLAB?

I'd like to plot data x & y with errorbars, ebar, and its fit, yfitted, on a semilog plot. This doesn't seem to work:

figure;
hold on;
errorbar(x,y,ebar);
semilogy(x,yfitted);

Instead of semilog plot I get a linear plot. What should I be doing differently?

Answers


try

h = errorbar(x,y,ebar);
set(get(h,'Parent'), 'YScale', 'log')

or

ax = axes();
errorbar(ax, x,y,ebar);
set(ax, 'YScale', 'log');

This is what the documentation says.

"If you attempt to add a loglog, semilogx, or semilogy plot to a linear axis mode graph with hold on, the axis mode will remain as it is and the new data will plot as linear"

I would suggest that you just reverse the order of your plotting, that is.

semilogy(x,yfitted);
hold on;
errorbar(x,y,ebar);

Need Your Help

Conversion of Hex to Int behaves differently in different environments

c++ linux qt qt-creator

There's this piece of code that works fine in QtCreator (on Windows 7) but behaves differently when running on a linux based embedded platform and I'm not sure how to begin debugging it.

System.ArgumentException: Destination array was not long enough

c# tcpclient

I am trying to work with a tcp it service that requires me to send an ID as string. I got the method below from a sample code.