MATLAB: Bar plot

bar

I am making a bar plot. I want to put text labels for each x value. the text lables, however, are located at the end of each bar on X axis. I wonder how I can put them in the center of bars. I apperciate your help.

Best Answer

Using my magic ball I will try to answer the question with one example made by me and based on the reference at the bottom
fruit = [2 5 6 7]
h=bar(fruit)
l={'apples', 'oranges', 'strawberries', 'pears'}
y=get(h,'Ydata');
x=get(h,'Xdata');
text(x-x(1)/3,y/2,l,'FontSize',18)