How to add a horizontal line in a bar plot????
38 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all,
i use the command bar for a plot. I want to insert a horizontal line in a bar plot at y = 30. How can I do that? Thank you!
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 1 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 1 Fév 2013
xlim=get(gca,'xlim');
hold on
plot(xlim,[30 30])
2 commentaires
Image Analyst
le 1 Fév 2013
Isn't the first line unnecessary? xlim is already the x limits - you don't have to call get() to retrieve it, it's already ready to be used "as is". xlim is actually a function itself that returns the x limits.
Plus de réponses (1)
Vivian Hauss
le 19 Juil 2016
Modifié(e) : Vivian Hauss
le 19 Juil 2016
A bit shorter:
hline(30,':k','This Line is horizontal')
1 commentaire
Voir également
Catégories
En savoir plus sur Bar 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!