Don't want my points on the boundary
1 view (last 30 days)
Show older comments
David Epstein
on 30 Apr 2019
Commented: Alex Mcaulley
on 30 Apr 2019
This code puts my points on the boundary of the plot , which
I don't want. Have tried setting xlim large, and various
other approaches. Any enlargement would help.
close all;
s = 2;
ss = -s:s;
[x,y] = meshgrid(ss);
plot(x,y,'ko');
hold on;
xticks([-s-1:s+1])
4 Comments
Alex Mcaulley
on 30 Apr 2019
This code should work:
s = 2;
ss = -s:s;
[x,y] = meshgrid(ss);
plot(x,y,'ko');
hold on;
xlim([-3,3])
ylim([-3,3])
xticks(ss)
yticks(ss)
![tonteria.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/217255/tonteria.png)
Accepted Answer
Alex Mcaulley
on 30 Apr 2019
Here we are:
s = 2;
ss = -s:s;
[x,y] = meshgrid(ss);
plot(x,y,'ko');
hold on;
xlim([-3,3])
ylim([-3,3])
xticks(ss)
yticks(ss)
1 Comment
More Answers (1)
KSSV
on 30 Apr 2019
s = 2;
dx = 0.5 ; % can be changed to your desired offset
ss = -s+dx:s-dx;
[x,y] = meshgrid(ss);
plot(x,y,'ko');
hold on;
xticks([-s-1:s+1])
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!