No BSD License  

Highlights from
barerrorbar

5.0

5.0 | 5 ratings Rate this file 5 Downloads (last 30 days) File Size: 5.86 KB File ID: #9541
image thumbnail

barerrorbar

by Kenneth Morton

 

06 Jan 2006 (Updated 21 Mar 2006)

Create a bar plot with error bars.

| Watch this File

File Information
Description

Barerrorbar() creates a bar plot with error bars. Although, not the first function to accomplish this task, barerrorbar() differs in that it directly calls the MATLAB functions bar() and errorbar() so that the options of both functions are preserved. For example:

x = 0.2*randn(3,4,100) + 1;
xMeans = mean(x,3);
xMeansL = repmat(3*0.2/10,3,4);
xMeansU = repmat(4*0.2/10,3,4);
barerrorbar({3:5,xMeans,'m'}, {repmat((3:5)',1,4),...
xMeans, xMeansL,xMeansU,'bx'});

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
BarsWithError, Barerror

MATLAB release MATLAB 7.1.0 (R14SP3)
Other requirements Does NOT work for 'stack' bar plots.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
20 Jul 2006 Leah Acker

Great program.

15 Nov 2006 Carolina Wählby

Beautiful!
I tried hard to find this functionality in Matlab, but almost decided to do my plotting in Excel to get arrorbars on my barplots... Thanks!

09 Apr 2009 Darik

Perfect. Every other bar/errorbar function on the FEX should be deleted.

13 Apr 2009 ollydbg

Great! It is better than the other bar and error bar related code

02 Jun 2011 Luka  
06 Jul 2011 Daniel

Very useful, is there anyway to make the error bars one sided? By that I mean to only have the top half of the error bar showing as opposed to the entire thing?

01 Sep 2011 omzaz

For the final figure in the example code, I want to set the first group of bars (at x = 1) black and the second group (at x = 2) red.

Adapting the example code, I assumed I could do this:
figure
barerrorbar({1,xMeans(1,:),'k'}, {[1 1 1 1],xMeans(1,:), xMeansL(1,:),xMeansU(1,:),'bx'});
hold on
barerrorbar({2,xMeans(2,:),'r'}, {[2 2 2 2],xMeans(2,:), xMeansL(2,:),xMeansU(2,:),'bx'});

However, this gives an error. Could someone please advise on what the code should be?
Thanks.

Please login to add a comment or rating.
Updates
10 Jan 2006

Fixed a spelling error in the description. Resized the example picture.

21 Mar 2006

Updated the file to remove M-Lint messages.

Tag Activity for this File
Tag Applied By Date/Time
annotation Kenneth Morton 22 Oct 2008 08:11:35
customization Kenneth Morton 22 Oct 2008 08:11:35
bar Kenneth Morton 22 Oct 2008 08:11:35
errorbar Kenneth Morton 22 Oct 2008 08:11:35
plot Kenneth Morton 22 Oct 2008 08:11:35
graphics Kenneth Morton 22 Oct 2008 08:11:35

Contact us at files@mathworks.com