![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/215544/image.jpeg)
bar plot ylim problem
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to set some blank space in y axis in a bar plot. ylim doesn't work. I just don't want to have a tight ylim plot (I need some blank space above the data, actually).
here is my code:
figure
uu=[6 5 7;8 6 4; 7 5 9];
nm={'DLC','TOU','RTP'};
nmc=categorical(nm);
bar(nmc,(uu))
legend('n','m','k')
here is the result:
![ress.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/215542/ress.jpeg)
0 commentaires
Réponse acceptée
Adam Danz
le 23 Avr 2019
Modifié(e) : Adam Danz
le 23 Avr 2019
ylim() does work.
ylim([0,15]) %at the end of your code; shown in the figure below.
Or you can make it flexible. This line below adds space that equals 10% of your highest bar.
h = bar(nmc, uu);
maxBar = max(cellfun(@max, get(h, 'YData')));
ylim([0, maxBar*1.1])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/215544/image.jpeg)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!