Code covered by the BSD License  

Highlights from
Adjust error bar width

4.9

4.9 | 10 ratings Rate this file 148 Downloads (last 30 days) File Size: 1.86 KB File ID: #22826
image thumbnail

Adjust error bar width

by Arnaud Laurent

 

29 Jan 2009 (Updated 06 Feb 2009)

Adjust error bars width in an errorbar plot to a ratio of the x-axis or a length (x-axis units).

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

function errorbar_tick(h,w,xtype)
ERRORBAR_TICK Adjust the width of errorbars

ERRORBAR_TICK(H) adjust the width of error bars with handle H. Error bars width is given as a ratio of X axis lenght (1/80).

ERRORBAR_TICK(H,W) adjust the width of error bars with handle H. The input W is given as a ratio of X axis lenght (1/W). The result is independant of the x-axis units. A ratio between 20 and 80 is usually fine.

ERRORBAR_TICK(H,W,'UNITS') adjust the width of error bars with handle H. The input W is given in the units of the curent x-axis.

Acknowledgements
This submission has inspired the following:
Update error bar widths automatically on figure resize
MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (15)
18 Mar 2009 Moritz

Nice work! This has driven me crazy in the past, but not any more .

04 Jun 2009 Joey Doll  
31 Jul 2009 Sathish Krishnan

cool job!! but the feature does not retain when I change linear scale to log scale(i.e. the width is wider in log scale and is uncontrollable)

14 Aug 2009 Arnaud Laurent

Re: thanks for your input Sathish, you're right the script wasn't made for log scale. I'll update the file to take care of that.

08 Oct 2009 Dan Knudsen

Thanks very much! Easy to use and works great.

One quick tip, which is relatively obvious but might be nice to add to the help: If you'd like to get rid of the ticks entirely, it's as easy as calling: errorbar_tick(h,0,'units')

13 Dec 2009 alex m

good idea, but I'm new to matlab and am unsure of the variables h and xtype, could someone post an example?

14 Feb 2010 Max

Works great! Thanks a lot!

11 Jun 2010 Tobias

Thanks for sharing your solution! It works fine as long as I one have one error bar series in a plot but I can't get it to work when I have more (as in> errorbar, hold on, errorbar). Do you have a fix for this?

06 Jul 2010 Tim DuBois  
27 Jul 2010 Anton Daneyko  
26 Mar 2011 Lin Li  
27 Jul 2011 Tom Etzer  
30 Aug 2011 Frank Coumans  
15 Nov 2011 Felipe G. Nievinski

It's great that this function operates on the handle output by the errorbar function, rather than duplicating what the errorbar function already does.

21 Nov 2011 Felipe G. Nievinski

You might want to insert this at line # 39:

if ~isscalar(h)
  arrayfun(@(h) errorbar_tick(h,w,xtype), h);
  return;
end

Please login to add a comment or rating.
Updates
02 Feb 2009

Header updated with examples, screenshot provided

02 Feb 2009

Screenshot updated

06 Feb 2009

The function has been updated to enable the use of a length as an input.
A new screenshot was made.

Tag Activity for this File
Tag Applied By Date/Time
errorbar Arnaud Laurent 29 Jan 2009 17:01:39
errorbar width Arnaud Laurent 29 Jan 2009 17:01:39
error bars Arnaud Laurent 29 Jan 2009 17:01:39
confidence interval Arnaud Laurent 29 Jan 2009 17:01:39
errorbar Kristian Nielsen 08 Dec 2009 08:39:56
error bars Kristian Nielsen 08 Dec 2009 08:40:01
errorbar width Kristian Nielsen 08 Dec 2009 08:40:04
confidence interval Kristian Nielsen 08 Dec 2009 08:40:12
errorbar Anton Daneyko 27 Jul 2010 07:52:16
cap Anton Daneyko 27 Jul 2010 07:52:16
error bar cap Anton Daneyko 27 Jul 2010 07:52:16
error bars Anton Daneyko 27 Jul 2010 07:52:16
error bar cap Driss 19 Feb 2011 16:49:36
cap Driss 19 Feb 2011 16:49:36
errorbar Bo Xiong 23 Apr 2011 04:44:28
error bar cap Hui 24 Oct 2011 18:38:23
potw Lindsay Coutinho 18 Nov 2011 08:52:03
pick of the week Lindsay Coutinho 18 Nov 2011 08:52:03

Contact us at files@mathworks.com