File Exchange

image thumbnail


version (5.86 KB) by Felix Zoergiebel
plots data with x and/or y error bars and supports logarithmic scaling for both axes.


Updated 14 Feb 2009

View Version History

View License

ploterr is a universal tool for plotting data with error bars. The following features are supported:

- linear/logarithmic scaling
- x and/or y error bars
- relative/absolute errors
- width of bar handles adjustable

Basically it unifies the features of errorbarxy, errorbarloglog, errorbar_x and errorbar in one single program.

For a detailed description and examples see the documentation in the file.

The technique for plotting the error bars is adapted from MATLAB's v6 errorbar, which is also used by Goetz Huesken's errorbar_x. With this technique the x error bars as well as the y error bars are one big line object, in contrast to errorbarloglog where each single error bar consists of three separate lines. That prevents an overflow of the legend with lots of separate line objects and makes it a lot easier to change the line style of the error bars.

Cite As

Felix Zoergiebel (2021). ploterr (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (34)

Matthew Styslinger


Rick Adams


THANKS! Helped a lot

Mohammad Heriyanto

William Barnes

Very useful but.... Is it possible to use a log10 rather than log (i.e. to use log base 10 rather than log base e) for the axes. For example, I tried log10x instead of log, but no joy.

Presper Eckert

Excellent functionality and very useful!


Thank you for this file!

I also wanted to ask you, is there a way to integrate those x-y errors with cftool or at least some kind of fitting that takes the errors into account?
I failed to find useful information online.

Thanks again,


Great file! Very helpful. Thank you!

Alex Carisey

James Hickey

Is there a way to change the width/length of the 'T' marks at the end of the errorbars?

Jiaxin Han


Hi Felix,
Here's a small mistake catching mechanism that can be added:
I'm using ploterr with the toggle for 'logxy' on, and I didn't realize that there were some points that would be negative with error bars, and I tried plotting them, and ploterr "did" without returning any error. I thought the plot looked a little sparse, and I couldn't figure it out until I finally noticed these tiny pixels on my graph. I'm not quite sure what they are because I haven't looked into ploterr, but it seems that feeding points where data-error<=0 (I tried 0 as well), makes ploterr plot these tiny pixels on your graph instead of the real points you wanted. They're very hard to see, and I missed them the first dozen time I look at my graph; so, it may be handy to provide some kind of error message when that happens.

Nitay Megides

I'd like to report a bug:
When using several plots with ploterr, the legend acts a bit funny:
1. The colors of the different plots is the same as the first plot (only in the legend)
2. The plot order is reversed

Nitay Megides

Another issue with the legend: The plots order is reversed


Hi, can someone give an example how more then 1 line can be plotted together?
for example: x = 0:15;
x1 = 5:20;
x2 = 10:25;
y =exp(-x).*(rand(1,16)*0.9+0.1);

I could not figure out how to do it by ploterr([x1 x2 ... xn],[y1 y2 ... yn],....) so I tried it the way as below, but can not get the legend of all entries.

h =ploterr(x,y,0.3,{exp(-x)*0.1 exp(-x)},'r.','logx','hhxy',0.5)
set(h(2),'Color','b'), set(h(3),'Color','b')
hold all;
h =ploterr(x1,y1,0.4,{exp(-x)*0.2 exp(-x)},'k.','logx','hhxy',0.4)
set(h(2),'Color','k'), set(h(2),'Color','k')
h =ploterr(x2,y2,0.5,{exp(-x)*0.3 exp(-x)},'b.','logx','hhxy',0.3)
set(h(2),'Color','r'), set(h(3),'Color','r')
legend(h,{'data' 'error x' 'error y'})




Abhinand Jha

How can i change the width of the horizontal errorbars?

Nicholas Valles

Thank you for this file, it does just what I want it too.


Thank you, Felix, for this excellent function! Erik Benkler (who posted above) is right: ploterr really is the Swiss Army Knife of error bar plots.

Anna Avdeeva

Anna Avdeeva

I have read your comment, that function can handle more than one plot, using
ploterr([x1 x2 ... xn],[y1 y2 ... yn],....) .
However I am having difficulties with plotting two curves using two user set styles ('^r','logxy' and 'ob','logxy').
Could you please let me know how to solve this?

Thank you in advance,

Erik Benkler

this is the swiss army knife for errorbar plots. Earlier, I have made a similar submission on file exchange, but I recommend to use ploterr.m

Felix Zoergiebel

1. The function can handle more than one plot, however the syntax you proposed is not supported. If all data is of the same length, you can plot several graphs at one time with
ploterr([x1 x2 ... xn],[y1 y2 ... yn],....)
Each column will plot to one line. See the help for details. (doc ploterr)
If you want to plot several lines with different numbers of data points, plot them one after the other:
for i=1:n, ploterr(x{i},y{i},xerr{i},yerr{i}), hold all, end

2. The nomenclature works fine for me. erry makes "vertical" error bars, errx makes "horizontal" error bars.



Can this function handle more than one plot?

e.g., ploterr(x1,y1,errx1,errx2,x2,y2,errx2,erry2...)

Also I think the nomenclature is backwards:

e.g. ploterr(x1,y1,erry1,errx1) is how it really works.


Daniel Hauser

thx, it everything works really fine, your m-file helps me alot with my analyses!


Daniel Hauser

Felix Zoergiebel

I do not really understand what you want to do, but I guess it's either of the following:
If you want to have errorbars on each of the interpolated points, do


If you want the interpolated points plotted as a line and only the "raw data" as points with errorbars, you can do that with two consecutive plot commands:

hold on, plot(x1,y1), hold off

Hope that helps,

Daniel Hauser

hi, first of all, your programm is great!!! but is it possible to add your errorbars to an interpolated function:


with error: xerr=0.02, yerr=0.5

thx daniel


with the bugfix it works fine

Felix Zoergiebel

The bugfix is online, I am looking forward to your comments!

Felix Zoergiebel

I'm sorry about that. I forgot to test the last update for use with no options. Here's a fix you can use until the new version is online:

Add those to lines to the beginning of the getproperties function:

function [sym,lx,ly,hx,hy] = getproperties(A)
lx=0; ly=0; hx=2/3; hy=2/3; sym='-'; % presets
if isempty(A), return, end


>> x = 2:11;
>> y = sin(x);
>> e = std(y)*ones(size(x));
>> ploterr(x,y,e)

??? Index exceeds matrix dimensions.

Error in ==> ploterr>getproperties at 318

Error in ==> ploterr at 136

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

Inspired by: errorbar_x

Inspired: errbar, errorbarxy, superbar

Community Treasure Hunt

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

Start Hunting!