5.0

5.0 | 3 ratings Rate this file 150 Downloads (last 30 days) File Size: 2.48 KB File ID: #30639
image thumbnail

Bar Chart with Error Bars

by Martina Callaghan

 

04 Mar 2011 (Updated 15 Nov 2011)

This is a very simple extension of MatLab's bar function to add error bars.

| Watch this File

File Information
Description

This acts in the same way as MatLab's bar function but with an additional first parameter containing the errors on the y values.
The y values are plotted using MatLab's bar function.
The x values are determined from the bar plot and used with MatLab's errorbar function to add errorbars to the bar chart that are centred on the column.
Adding an extra dimension to the errors allows for asymmetric errors.

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (12)
08 Mar 2011 Zachary Danziger

What is the relevant difference between this code and submission #24718 specifically (or generally submissions #27387, #25613, #9377, or #9541)?

This is not a critique specific to this code, which is probably fine, but is there some way to reach a consensus on which of these functions is best? Or perhaps merge these submissions, or create a new umbrella submission for all of these? At any rate, the author should cite some of these predecessors.

08 Mar 2011 Zachary Danziger

Sorry, maybe its easier to search for files with file names instead of file IDs:

24718-bar-with-errorbars
27387-create-healthy-looking-error-bars
25613-barrerror-utility-for-bar-plots-with-automatic-error-bars
9377-barerror
9541-barerrorbar

09 Mar 2011 Martina Callaghan

The ones I came across (barerror #9377 & barweb #10803) are much more complex. With complexity came the need for extra parameters and less user control.
This submission is just a basic extension of MatLab's bar and errorbar functions, which are cited!
I don't have the time to go through all of the other versions to compare. If you do, feel free to post how you get on.

25 May 2011 Quoc Viet Hung Nguyen  
19 Oct 2011 sinoTrinity Liu

The errors are symmetric. How can I add asymmetric errors?

24 Oct 2011 Martina Callaghan

I have just gotten around to updating this so that it can be called with asymmetric error bars. Add an extra dimension to the erros so as to specify the upper and lower in each. Hope this helps.

28 Oct 2011 Bolu Ajiboye

You stated that you came across other error bar scripts (like barweb, which has been around at least 6 years) but completely failed to acknowledge them.

28 Oct 2011 Martina Callaghan

The other options I came across were barerror #9377 & barweb #10803 as noted earlier. They were too complex for what I wanted. This submission is not an extension of any other hence no reference. It is something I find useful and have submitted in case others would too. If not of use, no problem.

11 Nov 2011 Jens

The asymmetric errors seem to work only with grouped/2D data

16 Nov 2011 Martina Callaghan

Asymmetric errors on 1D/2D data now working.

04 May 2012 Alex

Works great for me, thanks!

04 May 2012 Don Vaughn

Simple. Quick. Easy. Exactly what I was looking for

Please login to add a comment or rating.
Updates
12 Aug 2011

Now accounts for the fact that if x-values are also supplied, they may not be in ascending order.

24 Oct 2011

This version allows for asymmetric errors as requested.

15 Nov 2011

Now allows asymmetric errors on 1D data.

Tag Activity for this File
Tag Applied By Date/Time
error Martina Callaghan 04 Mar 2011 09:57:38
bar Martina Callaghan 04 Mar 2011 09:57:38
errorbar Martina Callaghan 04 Mar 2011 09:57:38
bar chart Martina Callaghan 04 Mar 2011 09:57:38
graph Martina Callaghan 04 Mar 2011 09:57:38
plotting Martina Callaghan 04 Mar 2011 09:57:38
errorbar ^9 09 May 2011 07:42:53
error bhanu kamapantula 28 Mar 2012 21:00:16
errorbar bhanu kamapantula 28 Mar 2012 21:00:25

Contact us at files@mathworks.com