How to add a dashed horizontal line at 0 using plot function?
434 views (last 30 days)
Adam Danz on 29 Sep 2019
Edited: Adam Danz on 2 Oct 2019
Here are 3 options to add a dashed horizontal line to a plot. The 1st option is recommended if you're using matlab r2018b or later.
% Use yline() to plot a horizontal line at y=0 (requires r2018b or later)
% This will automatically adjust if your xlim changes.
% Plot a line at y=0 that spans from x=0 to x=5
% Plot a line at y=0 that spans the current x-limits of your axes