How to draw a verical line to x-axis in a graph?

Illustration
Mariahernandez - 2020-08-31T10:49:03+00:00
Question: How to draw a verical line to x-axis in a graph?

If a = [1 2 3 4 5 6 7]; and b = [1 4 7 10 7 4 1]; and the plot it by : figure,plot(a,b), how can I draw let's say a red line vertical to the value 3 and 5 in the x-axis? So that i can see the window between 3 and 5.

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

yL = get(gca,'YLim');
line([3 3],yL,'Color','r');
line([5 5],yL,'Color','r');


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!