Code covered by the BSD License  

Highlights from
barweb (BARgraph With Error Bars)

4.70909

4.7 | 57 ratings Rate this file 331 Downloads (last 30 days) File Size: 2.78 KB File ID: #10803
image thumbnail

barweb (BARgraph With Error Bars)

by Bolu Ajiboye

 

20 Apr 2006 (Updated 01 Oct 2009)

Plots a fully customizable grouped bar graph with error bars

| Watch this File

File Information
Description

barweb.m calls the BAR and ERRORBAR MATLAB functions to produce bar graphs with error bars. The resultant graph is fully customizable, from group naming to legend inclusion to colormap setting. It assumes an m-by-n y-input matrix and plots m groups of n bars. The errorbar matrix must be setup the same way as the barvalues matrix (i.e. same dimensionality, matched values must have same indexes)

Syntax:
barweb(barvalues, errors, width, groupnames, bw_title, bw_xlabel, bw_ylabel, bw_colormap, gridstatus, bw_legend)

Acknowledgements
This submission has inspired the following:
BarTwoYaxis, barwebpairs (pair bars within groups and between groups), Create Healthy Looking Error Bars
MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (68)
23 Apr 2006 Shai Shen-Orr  
23 Apr 2006 Jiro Doke

Pretty good, but it doesn't leave the user much control to make modifications. You should at least return the handles of the bar and errorbar objects, so that the user can modify their properties. Along the same line, you should also return the handle of the legend axes. I prefer leaving the legend (as well as title and labels) out for the user to do on their own, since it allows them to customize properties like position, fontsize, fontweight, etc.

24 Apr 2006 Angela Chapman

Unfortunately for me, not compatible with Matlab 6.0.

31 Aug 2006 Scott G

Small problem with group labelling in R14.

Fix on line 124:
Add additional arguments to set(...)

set(gca, ..., 'XTick', 1:numgroups);

01 Mar 2007 Michael Frank

Nice! produces very pretty graphs, generally very easy to use.

11 Apr 2007 Richard Cui

Neat job!

31 May 2007 James Blake

Works well with R2006a. Nice and easy to change the colours of the bars and such.

01 Jun 2007 Will Hunting

Thanks a lot !

08 Jul 2007 Richard Lemon

This works very well. What a big help. Thanks!

17 Dec 2007 germana ba

thank you so much!

20 Dec 2007 Steve Fleming

One of the very few oversights in the graphics toolbox is not having an easy way of plotting error bars! This is great and saved me a lot of time.

05 Feb 2008 Diana Bedolla

For the plotting it works really good, but when I introduce the groupnames it repeats the same
first groupname in each x-tick. Any idea what could be the problem?? Thanks for the file!!

07 Feb 2008 J X

This is very helpful, which helped me draw the graphs in a few secs.

12 Feb 2008 John Elve

The script itself is good but it lacks the possibility of a variable number of input arguments!

14 Feb 2008 Dimka P

Very helpful! Thanks!

03 Apr 2008 Andy C

Just what I always wanted.

03 Apr 2008 Juan Hincapie

Exactly what I needed!

10 Apr 2008 Kim Bostroem

Coolomat!
Why hasn't the great Matlab thought of this himself? It's SO useful!

15 Apr 2008 H Hung

great stuff.. any chance of updating it so that the errors can have an upper and lower bound like the matlab errorbar function?

01 May 2008 Amanda Whitmire

Great - exactly what I needed. Thanks for sharing it.

04 Jun 2008 Y Guo

Thanks! Good job! Matlab should consider incorporating this!

20 Jun 2008 alyssa smith

you're my hero. this just saved me a mountain of trouble!!

02 Jul 2008 Ben Engel

This was a great help - thanks!

05 Aug 2008 A VanderWyst  
08 Aug 2008 Jorge T

Great! saved me a lot of time!

08 Sep 2008 Brajendra Singh

Great!

10 Sep 2008 Lan Huong Vu Thi

Thanks. It is useful for me !

18 Sep 2008 Nikolay Stoykov

Great job, Bolu! Thanks.

14 Oct 2008 René Quilodran

Thanks Bolu !!!!! you did a great job!!!

16 Oct 2008 Kshitiz Gupta

Thanks. It is very useful.

09 Dec 2008 Mastaneh  
29 Apr 2009 Wenjia

Excellent! That is just what I need.

01 Jun 2009 Félix Chénier

Clean and simple, it does a very good job. Thank you

10 Jul 2009 Matthew  
22 Jul 2009 Greg Imamura

Great program- I modified mine to allow for lower and upper errors

01 Oct 2009 Jaroslav Hlinka

Thanks for the function! Useful, although I think I may have found an annoying bug: using 'error_sides = 1', when I save tiff file, it has the errorbar all the way down to x-axis (it is still ok when the initial figure is created). Using MATLAB R2007a on windowsXP. Any idea why/Any quick fix available?
PS. btw, the usage in the .m file might not be up to date - e.g. mentioning "barwebtype" parameter which is not amongst the function parameters.

07 Nov 2009 Roman Balabin  
26 Nov 2009 Arthur  
15 Jan 2010 Dung Chu

Great. I just need view(90, -90) after all to have horizontally-aligned bar charts.

18 Feb 2010 Luis Felipe Giraldo

Nice!

22 Feb 2010 Anke

really helpfull!

29 Mar 2010 Debanjan Goswami

Really nice and easy. But I have got a problem. I can't plot the 'X-tick' like type1, type2... written in the example figure. I have the text for each bar in a separate cell array. How to incorporate?

Thanks

01 Apr 2010 Jesse Brown

Handy function. One problem: when I save a figure with one-sided bars to .png or .tif, two-sides bars show up.

05 Apr 2010 Pearl  
14 May 2010 James

Thanks Bolu! This is what I was looking for.

15 May 2010 Ross

This is really nice. If using values in only one group (monthly rain data, for example), is there any way to add labels to the x-axis?

30 Sep 2010 Jeff Chen

Works GREAT!

14 Oct 2010 C G

Great. Thanks!

15 Oct 2010 Patrick A.  
03 Nov 2010 Erin

to plot bars horizontal
view(90, -90)

or view(-90, 90)

11 Nov 2010 Juan Carlos

Thanks!

08 Dec 2010 Ali Ali

Thanks a lot

16 Jan 2011 Karen

It would be nice if we could set different upper and lower error values... Otherwise quite cool

30 Mar 2011 Casey Ta  
30 Mar 2011 Casey Ta

Thanks, this was very helpful!

01 Jul 2011 Rachel

what are the options to set the gridstatus input to?

11 Jul 2011 Arturo Moncada Torres  
14 Jul 2011 Pearl

Thank you!

16 Jul 2011 musi

Pretty great:

it is working

 % groupnames
{'1000', '2000', '5000', '10000', '15000', '20000', '25730'},

16 Jul 2011 musi

(The above statement is to put samples values associated with each bar in the x-axis)

18 Jul 2011 Arturo Moncada Torres

Nice file. I recommend you to look at this post (http://blogs.mathworks.com/loren/2009/05/05/nice-way-to-set-function-defaults/) regarding variable inputs for functions.

Keep up the good work ;-)

28 Jul 2011 dani din  
16 Aug 2011 amit Singh

good

02 Sep 2011 Yi YIN  
26 Oct 2011 Mariana  
24 Nov 2011 Hong

good job

03 Jan 2012 David

I seem to have run into a bug. I want to have a single bar for several groups and I set the groupnames variable to the names I want. But I end up with one group and multiple bars. I've tried inputing an mx1 vector and 1xm vector to see if that's the problem but both times I get the same results. Commenting out lines 120 and 121 fixed it. Any ideas?

04 Jan 2012 Parul Srivastava

how to plot with secondary axis means values of two bars on two different y axis

Please login to add a comment or rating.
Updates
24 Apr 2006

Revised based upon M-Lint Code Report.

No functional revisions...code has just been spaced for better readability.

24 Apr 2006

Revised based upon M-Lint Code Report.

No functional revisions...code has just been spaced for better readability.

24 Apr 2006

Updated based upon the M-Lint code report. No functional changes were made. The code was just spaced out for easier reading and comprehension.

07 Dec 2006

Updated to return handles to different aspects of plot

28 Sep 2009

1) Now able to plot 1 vs 2-sided barwebs
2) Now able to show legend along x-axis or on standard plot
3) Made code more robust by using bar children features rather than calculating x positions manually
4) other small fixes

01 Oct 2009

Changed the usage information

Tag Activity for this File
Tag Applied By Date/Time
specialized Bolu Ajiboye 22 Oct 2008 08:22:41
plotting Bolu Ajiboye 22 Oct 2008 08:22:41
bar graph Bolu Ajiboye 22 Oct 2008 08:22:41
barweb Bolu Ajiboye 22 Oct 2008 08:22:41
customizable Bolu Ajiboye 22 Oct 2008 08:22:41
error bars Bolu Ajiboye 22 Oct 2008 08:22:41
graphics Bolu Ajiboye 22 Oct 2008 08:22:43
barweb Ryan Prantil 30 Oct 2010 20:33:24
bar graph Guido Orgs 17 May 2011 11:22:32
bar graph Hsu 22 May 2011 16:04:07
bar graph amit Singh 16 Aug 2011 08:39:26
bar graph Satyanarayanan 09 Oct 2011 13:33:46
bar graph tmd 22 Nov 2011 16:01:07
error bars Tero 18 Jan 2012 03:38:18

Contact us at files@mathworks.com