Changing y-axis for Bar graph
22 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Aftab Ahmed Khan
le 21 Avr 2015
Réponse apportée : Star Strider
le 21 Avr 2015
Hi Everyone, I am plotting these bar graphs but i want the y-axis to be from 3 sec to 4 sec. So to make the variation more visible among the three. Any help guys?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149283/image.png)
0 commentaires
Réponse acceptée
Star Strider
le 21 Avr 2015
You have to subtract 3 from your bar y-values, then plot and re-label your y-axis:
xtl = {'4-2' '3-2' '3-2' '4-1' '3-1' '2-1'};
data = rand(6,3)+3;
figure(1)
hb = bar(data-3)
set(gca, 'XtickLabel', xtl)
set(hb(1),'FaceColor','c')
set(hb(2),'FaceColor','k')
set(hb(3),'FaceColor','r')
set(gca, 'YTick', [0:0.1:1], 'YTickLabel',[0:0.1:1]+3)
You will have to experiment with your data to work this in with it, but the techniques should be straightforward. Note that the 'YTick' values go from 0 to 1, but the labels go from 3 to 4. That’s the only ‘trick’ involved.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations 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!