Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Edit error bars on bar chart

Subject: Edit error bars on bar chart

From: Daniel Robbins

Date: 19 Jun, 2012 12:13:06

Message: 1 of 3

Hi,

I am using the follwoing code to produce a bar chart:
b = mean points of data
d = standard deviation of data
bar(b)
hold on
errorbar(b,d)
hold off

This code produces a bar chart with error bars in both upward and downward directions. I am struggling to follow the nat;ab help section on how to edit teh error bars to only produce the upper error bars. There is also little information that can be ofund via googling.

Any help will be greatly appreciated.
Thanks
Dan

Subject: Edit error bars on bar chart

From: Steven_Lord

Date: 19 Jun, 2012 13:22:21

Message: 2 of 3



"Daniel Robbins" <d.w.e.robbins@gmail.com> wrote in message
news:jrpqci$8o3$1@newscl01ah.mathworks.com...
> Hi,
>
> I am using the follwoing code to produce a bar chart:
> b = mean points of data
> d = standard deviation of data
> bar(b)
> hold on
> errorbar(b,d)
> hold off
>
> This code produces a bar chart with error bars in both upward and downward
> directions. I am struggling to follow the nat;ab help section on how to
> edit teh error bars to only produce the upper error bars. There is also
> little information that can be ofund via googling.

You're using the errorbar(Y, E) syntax for ERRORBAR. Use the errorbar(X, Y,
L, U) syntax instead.

http://www.mathworks.com/help/techdoc/ref/errorbar.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Edit error bars on bar chart

From: Daniel Robbins

Date: 19 Jun, 2012 13:45:07

Message: 3 of 3

> You're using the errorbar(Y, E) syntax for ERRORBAR. Use the errorbar(X, Y,
> L, U) syntax instead.
>
> http://www.mathworks.com/help/techdoc/ref/errorbar.html

Hi Steve,

Thanks for getting back to me. I have been thinking on the lines you suggest. The issue I have is that my data is a series of 1D values e.g. b = [1 2 3 4 5 6]. Therefore effectively I only have y values and no x values.

Do I need to produce a simple scale to produce X values? e.g. c=(1:1:length(b)) ?

I could use this and then put errorbar(b,c, L, U) where L=zeros(length(b) and U = standard deviations?

Though I have read some posts online which indicate if you apply this technique there are still lower error bars produced which, although obviously tiny (in reality on the horizontal section displayed) the graph would look better without.

Thanks again
Dan

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us