Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How do I insert values into my bar plot (with 2 columns per x
value)?

Replies: 1   Last Post: Jan 29, 2013 5:24 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
dpb

Posts: 7,885
Registered: 6/7/07
Re: How do I insert values into my bar plot (with 2 columns per x
value)?

Posted: Jan 29, 2013 5:24 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 1/29/2013 3:17 PM, Chris wrote:
> If I have a vector A and matrix B and make a bar plot, how do I list the
> corresponding y values at the top of each bar? (I understand that you
> use the text() function but I cannot get it to work). An example of what
> I want to accomplish:
>
> A = [1 2 3 4 5];
> B = [4 7; 2 9; 3 7; 4 8; 1 3];
> bar(A,B);
>
> % how do I properly use text() or something else to insert the data
> values located in B??


Try

text(A(1)-.2,B(1,1)+.25,num2str(B(1,1)))

at the command line for example. You can then clearly use a loop or
even vectorize the idea for the general case.

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.