Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: How do I insert values into my bar plot (with 2 columns per x

$
0
0
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.

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles