I'm creating a histogram "manually" in MATLAB using the plot
command on a dataset after using the hist
command (where I can assign the output of the command to two matricies) to manually get the counts and midpoints. What I would really love to do is add a label above each of the bars on my histogram stating the centerpoint value of that column.
Since I already have a vector containing all of those center values, my issue lies in figuring out how to actually create the labels and place them above each of the bars. Any help in adding these would be greatly appreciated!
What I've Tried So Far:
Based on another StackOverflow post, I saw a command along these lines
for b = 1:nBins
text(bins(b),counts(b)*2,num2str(a(b==binIdx,1)),'VerticalAlignment','top')
end
I get the idea that I probably use the text
command inside a loop to place a label above each bar, but when I attempted to modify the text
command above to the data I had, I could not see the labels on my plot.