How to add a horizontal line in a bar plot????
53 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Thor
am 1 Feb. 2013
Bearbeitet: Pablo Sánchez
am 8 Dez. 2020
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 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 1 Feb. 2013
Bearbeitet: Azzi Abdelmalek
am 1 Feb. 2013
xlim=get(gca,'xlim');
hold on
plot(xlim,[30 30])
2 Kommentare
Image Analyst
am 1 Feb. 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.
Weitere Antworten (1)
Vivian Hauss
am 19 Jul. 2016
Bearbeitet: Vivian Hauss
am 19 Jul. 2016
A bit shorter:
hline(30,':k','This Line is horizontal')
1 Kommentar
Pablo Sánchez
am 8 Dez. 2020
Bearbeitet: Pablo Sánchez
am 8 Dez. 2020
Does hline() exist? Is yline()
Siehe auch
Kategorien
Mehr zu Bar Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!