Add lines along the axes

36 views (last 30 days)
Max Jetzer
Max Jetzer on 29 Sep 2018
Commented: Steven Lord on 30 Sep 2018
I need to add lines along the x and y axes, but I don't want to move the entire axis to the origin. (essentially gridlines, but only at x=0 and y=0) Is this doable easily?

Accepted Answer

Star Strider
Star Strider on 29 Sep 2018
I am not certain what you want.
Try this:
x = linspace(-2, 5, 250);
y = sin(2*pi*x + 0.2) + 0.3;
figure
plot(x, y)
hold on
plot([0 0], ylim, '--') % Dashed Vertical Line at x=0
plot(xlim, [0 0], '--') % Dashed Horizontal Line at y=0
hold off
grid

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!