![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/290036/image.png)
how to write the legend in bar chart
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ibrahim AlZoubi
il 3 Mag 2020
Commentato: Ibrahim AlZoubi
il 3 Mag 2020
how to add legend for the first, second and third column?
this is the code:
y =[44,55,54] ;
b = bar(y,0.5);
bar(y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/290033/image.png)
0 Commenti
Risposta accettata
Ameer Hamza
il 3 Mag 2020
Modificato: Ameer Hamza
il 3 Mag 2020
Try this
y =[44,55,54];
hold on
for i=1:numel(y)
bar(i, y(i))
end
legend({'first', 'second', 'third'})
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/290036/image.png)
14 Commenti
Ameer Hamza
il 3 Mag 2020
You can replace A, B and C with what you want
y =[44,55,54];
hold on
for i=1:numel(y)
bar(i, y(i))
end
xticks(1:numel(y))
xticklabels({'44', '55', '54'})
legend({'first', 'second', 'third'})
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Legend in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!