How to draw grid lines at specific x- and y-ticks?

조회 수: 41 (최근 30일)
Parthu P
Parthu P 2020년 1월 25일
답변: Parthu P 2020년 1월 31일
Hi,
I want to draw grid lines to a scatter plot only at tick '0'. The plot has x and y limits -1 to 1 and ticks at [-1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1].
How could I do this without changing x- and y-ticks and without any additional major/minor grid lines?

채택된 답변

Akira Agata
Akira Agata 2020년 1월 25일
How about using xline and yline functions?
The following is an example:
% Sample plot
figure
scatter(-1+2*rand(100,1),-1+2*rand(100,1))
ax = gca;
ax.XTick = -1:0.25:1;
ax.YTick = -1:0.25:1;
box on
% Add x = 0 and y = 0 lines
xline(0,'--')
yline(0,'--')
grid.png

추가 답변 (1개)

Parthu P
Parthu P 2020년 1월 31일
Thank you very much Akira!

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by