Data labels above bars on grouped bar plot
182 views (last 30 days)
I'm making a grouped bar plot (i.e., a bar plot with multiple bars in each category). I would like to add labels at the top of each bar to indicate its height. I was planning to just use the text function. However, bars within a given group all have the same x location (i.e get(h,'XData') is the same for all bar series). I'm not sure how to find the proper x location for each bar within a given group. Any ideas?
dpb on 16 May 2014
Edited: dpb on 16 May 2014
You're on the right track, the center of each group is at the axis tick value. For each bar in the group, use that value plus/minus a delta to locate the x position for your text.
I did an example of this for another poster within the last few weeks at most altho I don't have the link at hand. Perhaps a search will uncover it.
OK, I looked at past answers--this one is pretty close altho I thought I did another. Maybe it was in the newsgroup instead...
More Answers (5)
aliyar attaran on 4 Nov 2016
for 2 bars one one y value:
Halina H on 7 Dec 2017
Hi , I would like to know how to code to get the total value of each bar in this grouped bar graph ie , total bincounts for the yellow bar, total bincounts for blue bar , and total bincounts for green bar. I am interested to know which of these 3 bars give the most information