Change label frequency m_map

4 views (last 30 days)
pwprnt
pwprnt on 6 Mar 2017
Answered: Fernand ASSENE on 11 Aug 2020
My longitude tick labels are overlapping, and I cannot find in the documentation how to fix this or change tick frequency. I have only found how to change the m_map tick label properties (font size, etc.. ) but not the number of ticks.
Right now my code is
bndry_lon=[-176.5 -176.5 -160.0 -160 -176.5 -164.5 -164.5 -176.5];
bndry_lat=[71.2 72.9 72.9 71.2 71.2 71.2 69.304 69.304];
clf;
m_proj('mercator','long',[-179.0 -145], 'lat', [50, 75],'rectbox','on');
m_gshhs_i('color','k'); % coastline
m_gshhs_i('speckle','color','k'); % with speckle added
m_hatch(bndry_lon,bndry_lat,'cross',40,7,'color','k'); % ...with hatching added.
m_coast('patch',[.7 .7 .7],'edgecolor','k');
[CS, H] = m_elev('contourf',3,'b');
m_grid('linewi',2,'linest','none','tickdir','out','fontsize',12);
title('Chukchi domain of selected winds','fontsize',14);

Answers (1)

Fernand ASSENE
Fernand ASSENE on 11 Aug 2020
Hi pwprnt, i saw your question yesterday when i was trying to do the same thing as you. Finally i found the solution.
"help m_grid" shows wrong way to use "xtick" option i thing, It's very annoying. Or it works depending on MATLAB version you use, i don't know.
help proposes to use as :
'xtick',[ num | [value1,value2, ...] % num = number of ticks
Above a wright way to use this option that i found :
'xtick',([value1 value2, ...])
This is an example
m_grid('linewi',2,'linest','none','tickdir','out',...
% set "xtick"/"ytick" values as you want, but must ranging from min to max of each coordinate
'xtick',([-40 -30 -20 -10 0 10]),... % longitude
'xticklabel',{'40°W','30°W','20°W','10°W','0','10°E'}); % name longitude ticks as you want
'ytick',([-6 -4 -2 0 2 4 6])); % latitude
'xticklabel',{'6°S','4°S','2°S','0','2°N','4°N','6°N'}); % name latitude ticks as you want
I hope it will be useful for someone.

Community Treasure Hunt

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

Start Hunting!