View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

3.7 | 7 ratings Rate this file 12 Downloads (last 30 days) File Size: 2.91 KB File ID: #19002 Version: 1.3
image thumbnail




02 Mar 2008 (Updated )

Customizable error bar plot in X and Y direction

| Watch this File

File Information

A similar Matlab function, ploterr (FEX ID #22216), does all what this function does, plus some more. It should be preferred over this submission, which then might be deleted in a near future.

This function allows the user to plot the graph of x against y, along with both x and y errorbars.
With 4 numeric arguments (x,y,dx,dy), error bar are assumed to be of same magnitude in both direction.
One can specify lower and upper error bar with 6 numeric arguments (x,y,dx_high,dy_high,dx_low,dy_low).
x,y,dx,dy,... must be vectors of the same length.

[hp he] = errorbarxy(...) returns respectively the handle for the line plot object and the line error bar object.

It is possible to customize the line properties of the error bars by adding pair of 'field/value' fields (such as 'LineWidth',2) that can be understood by line. See LineProperties for more information.

X = 10 * rand(7,1);
Y = 10 * rand(7,1);
dx = rand(7,1);
dy = rand(7,1);

X = 10 * rand(7,1);
Y = 10 * rand(7,1);
dx = rand(7,1);
dy = rand(7,1);
dx2 = rand(7,1);
dy2 = rand(7,1);

This is a rewrite of the m-file errorbarxy of James Rooney, to add customizable line properties.

  Author: Jean-Yves Tinevez
  Work address: Max-Plank Insitute for Cell Biology and Genetics,
  Dresden, Germany.
  Email: tinevez AT mpi-cbg DOT de
  November 2007;
  Permission is given to distribute and modify this file as long as this notice remains in it. Permission is also given to write to the author for any suggestion, comment, modification or usage.


Errorbarxy inspired this file.

This file inspired Errbar and Errorbarxy.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
26 Mar 2016 Sourin

Sourin (view profile)

02 Feb 2016 Jay

Jay (view profile)

When using a log scale, the error bars don't look right. Any quick fix for this?

Comment only
28 Feb 2010 Kan Wu

Kan Wu (view profile)

very good

22 Jul 2009 Daniel Høyer Iversen

03 Nov 2008 Keith Brady

I found this function behaves oddly if the dx, dy, dx2 and dx2 vectors have negative values in them. Also it would be helpful if the doc described the return outputs. When apply legends to graphs you get two entries one for the data points and one for the error bars. This is easy to prevent as follows:

h = errorbarxy(x,y,dx,dy,dx2,dx2)
legend(h(1),'legend text')

15 Sep 2008 joe schmoe

didn't work at first, but then started by editing examples, and it worked. thanks.

13 Jun 2008 Lars Hoffmann

I still cannot find the missing function...

21 Apr 2008 Jean-Yves Tinevez

Error corrected, missing subfunction included in the file. Thanks to Brad Ridder for reporting.

Comment only
14 Apr 2008 Brad Ridder

It doesn't work.

Undefined function varargin2struct()

03 Mar 2008

Put a more recent with decent help version.

03 Mar 2008

Desperately trying to post the CORRECT file.

21 Apr 2008

Missing subfunction struct2varargin is now included in the file. Thanks to Brad Ridder for reporting it.

05 Nov 2008 1.1

From Keith Brady feedback, prevent oddities when entering negative error bar length

11 Feb 2009 1.2

Corrected minor bugs + updated picture

19 Feb 2009 1.3

Added a reference to the FEX ID #22216 which does similar thing, in a much complete and better way.

Contact us