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...

 채택된 답변

KL
KL 2017년 9월 20일

0 개 추천

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);

댓글 수: 2

Alex C
Alex C 2017년 9월 20일
Thank you for the quick answer KL but I have this with your code...
I have a R2014a matlab, does that have to do with anything? Or Do I have to enable something else when the figure opens?
The xticklabels function was introduced in R2016b. Replacing that line with this will probably work in R2014a:
set(gca, 'XTickLabel',labels);
I no longer have access to R2014a, so I can’t test it to be sure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2017년 9월 20일

댓글:

2017년 9월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by