Using errorbar () with semilogy () in MATLAB?

I would like to plot x and y data with errors, ebar and its fit, yfitted , on a semi-log chart. This does not work:

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

Instead of a semi-log graph, a linear graph is obtained. What should I do differently?

+6
math matlab plot graphing
source share
2 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'); 
+8
source share

This is what the documentation says.

"If you try to add a log, semi-log or semi-log graph to the linear axis graph with a hold, the axis mode will remain as it is, and the new data will be displayed as linear"

I would suggest that you simply canceled the order of your construction, that is.

 semilogy(x,yfitted); hold on; errorbar(x,y,ebar); 
+3
source share

All Articles