Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


dpb
Posts:
8,982
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


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.




