How to add a horizontal line in a bar plot????
96 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2013-2-1
编辑:Azzi Abdelmalek
2013-2-1
xlim=get(gca,'xlim');
hold on
plot(xlim,[30 30])
2 个评论
Image Analyst
2013-2-1
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.
更多回答(1 个)
Vivian Hauss
2016-7-19
编辑:Vivian Hauss
2016-7-19
A bit shorter:
hline(30,':k','This Line is horizontal')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!