File Exchange Pick of the Week

Our best user submissions

Add horizontal and vertical lines

Posted by Doug Hull,

How many times have you done something like this?

% BEGIN draw a horizontal line
xMin = 0; xMax = 10; % the current extents of the x axis
yVal = 12;

hold on
plot([xMin xMax], [yVal, yVal])
hold off
% END draw a horizontal line

Hline and Vline are simple but useful tools that draw a horizontal line at the given Y value from the left most extent of the axes to the right most. There is a similar command for vertical lines. You can replace the above with:

hline(yVal)

and be done with it.

51 views (last 30 days)  | |

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.