필터 지우기
필터 지우기

Change label frequency m_map

조회 수: 3 (최근 30일)
pwprnt
pwprnt 2017년 3월 6일
답변: Fernand ASSENE 2020년 8월 11일
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