How can I put data under a bar graph?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alex C
el 20 de Sept. de 2017
Comentada: Star Strider
el 20 de Sept. de 2017
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...

0 comentarios
Respuesta aceptada
KL
el 20 de Sept. de 2017
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 comentarios
Star Strider
el 20 de Sept. de 2017
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Bar Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
