How do I put gridlines on a map?

I know can use the code below(code1) to set the gridlines for this contour plot but I can't get gridlines to show up on the code below that(code2). Code2 shows a few gridlines that correspond to different latitudes and longitudes but I can't figure out how to create different gridlines on it with spacing of my choosing. I tried to do a code similar to code 1 but nothing happened.
CODE 1
figure
contour(XX,YY,ZZ)
grid on
set(gca,'xtick',-30000:500:5000)
set(gca,'ytick',-5000:500:30000)
CODE 2
latlim=[42.7 42.9];
longlim=[-71.05 -70.8];
gravityreading=grav;
figure
usamap(latlim,longlim);
states=shaperead('usastatehi','usegeocoords',true,'Boundingbox',
[-71.05,42.7;-70.8,42.9]);
geoshow(states)
contourm(Y,X,Z,'r')
[c,h]=contourm(Y,X,Z,'r');
ht=clabelm(c,h);
set(ht,'color','b');

Answers (0)

Asked:

on 10 Mar 2015

Edited:

on 10 Mar 2015

Community Treasure Hunt

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

Start Hunting!