![grid.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/268167/grid.png)
How to draw grid lines at specific x- and y-ticks?
35 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/268167/grid.png)
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!