How to add a horizontal line in a bar plot????
85 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Thor
el 1 de Feb. de 2013
Editada: Pablo Sánchez
el 8 de Dic. de 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 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 1 de Feb. de 2013
Editada: Azzi Abdelmalek
el 1 de Feb. de 2013
xlim=get(gca,'xlim');
hold on
plot(xlim,[30 30])
2 comentarios
Image Analyst
el 1 de Feb. de 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.
Más respuestas (1)
Vivian Hauss
el 19 de Jul. de 2016
Editada: Vivian Hauss
el 19 de Jul. de 2016
A bit shorter:
hline(30,':k','This Line is horizontal')
1 comentario
Pablo Sánchez
el 8 de Dic. de 2020
Editada: Pablo Sánchez
el 8 de Dic. de 2020
Does hline() exist? Is yline()
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!