Specific grid for scatter

6 views (last 30 days)
Tom
Tom on 2 Aug 2011
Hello,
I have a scatter plot with x-values of 0.75-1.25 and y-values of -500 and 500. I would like to add a grid for x = 1 and y = 0 to highlight the quadrants.
figure
scatter(x,y,'DisplayName','x,y')
xlabel('x')
ylabel('x')
title('Scatter')
axis([0.75 1.25 -500 500])
set(gca, 'XTick', 1, 'YTick', 0);
grid on
figure(gcf);
It adds the grid cross but omits all other values on the x- and y-axis except for 1 on the x-axis and 0 on the y-axis. Is there a way to keep the values for the axes and show the dimensions?
Thank you.

Accepted Answer

the cyclist
the cyclist on 2 Aug 2011
Remove the line where you set the XTick and YTick, and use this:
hv = line([1 1],[-500 500]);
hh = line([0.75 1.25],[0 0]);
set([hh hv],'LineStyle','--','Color','k')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!