File Exchange

image thumbnail


version (2.04 KB) by Frederic Moisy
Error bar plot for X-axis in log scale


Updated 24 Jan 2006

View License

ERRORBARLOGX Homogenize the error bars for X-axis in log scale.

ERRORBARLOGX turns the X-axis of the current error bar plot to log scale, and homogonizes the length of the horizontal segements which terminate the vertical error bars.

By default, Matlab's ERRORBAR draws vertical error bars which are terminated by small horizontal segments of uniform length for the X-axis in linear scale. But when turning the X-axis to log scale, these segments become uneven. Using ERRORBARLOGX makes them uniform again.

ERRORBARLOGX(N) specifies the relative length of the horizontal segments, normalized with the total range of the data. By default, N=0.01 is used.

Limitations: ERRORBARLOGX acts only on the last drawn curve. If this curve is not an error bar plot, it won't work.

y=5*(1 + 0.5*(rand(1,20)-0.5)).*x.^(-2);

Cite As

Frederic Moisy (2021). errorbarlogx.m (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (24)

Mario Koddenbrock

Sergei P.


David Collins

Miguel Ullan



The image is loglog errorbar, which is I need, but the code is logx error bar, can someone tell how to make the loglog happen?

Danmei Bian

Thank you so much!

Leonardo Sepulveda

Excellent. Easy to use.

Vincent G.

Great, it saved my day!
Thanks a lot!

Martin Hansen

I love it when someone has made just what I'm looking for! This is what the Matlab File Exchange is all about. Thanks!

Mark Runacres

Works great. Thanks!

Ipek Oruc


Philip Du Toit

Works great! Just what I needed.
Works with multiple curves in a single plot.

Alexei Tcherniak

Perfect! Very glad I was able to find such a thing. Makes you wonder why matlab doesn't have it by default

Uli Stark

thanks a lot - helped so much!

Chethan Pandarinath

perfect! thank you very much for this.

matthieu simon

Exactly what I need ! Thanks

Aiko Voigt

Bert Sels

Worked as described. Thanks!

lijun gou

Commands loglog + hold on + errorbar could do the same action.

Uwe Kätzel

Very useful, works pretty fine

Vincent Pelletier

I Google-searched for a solution to my problem, found your .m file first, and it works like a charm! Thanks!

Andi Petculescu

When I'm trying to run the example provided, the error bar "cap" length is *not* rescaled. I get the following error message:
"??? Index exceeds matrix dimensions.
On line 40 ==> heb = cd.Children(2); % handle to current error bars"

Any input is welcome!

(Matlab 6.5 R13)

Nick D

Amazingly useful, and I'm suprised that there isn't something like this built in (as far as I ahve seen)

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: superbar, errorbarlogy, eb_ticklength

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!