Change label frequency m_map

5 次查看(过去 30 天)
pwprnt
pwprnt 2017-3-6
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);

回答(1 个)

Fernand ASSENE
Fernand ASSENE 2020-8-11
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.

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by