MATLAB: How to put data under a bar graph

bar graph

Like the picture below (made in excel), I would like to add the production value under the bar graph.
I have a solution using text (?) but the example shown with that is way to advanced for what I want to do and I have difficulties to understand what he did…

Best Answer

data = [5 4.7 5.02];
year = [2015,2016,2017];
c = categorical({'2015','2016','2017'});
bar(data);
ylabel('Prod')
xlabel('Year')
title('Production')
labels = cellfun(@(x,y) [num2str(x),'\newline',num2str(y)], num2cell(data),num2cell(year),'UniformOutput',false);
xticklabels(labels);
Related Question