change ticklabels using m_map

25 次查看(过去 30 天)
Lena Frey
Lena Frey 2015-8-11
Hi!
I have problems to change ticklabels using m_map.
My labels for longitude and latitude are overlapping, so I tried to set specific labels for the longitude. The longitude range for my map is -180 to 180.
I have used the following command.
m_grid('xaxis','middle','xtick',5,'xticklabel',{'120W','60W','0','60E','120E'},'ytick',5);
The result with this command is always, that I got longitude labels from -180 to 180. I tried many other things which are recommended just for Matlab, but it is still not working.
Does someone know how to change the labels using m_map?

回答(1 个)

Fernand ASSENE
Fernand ASSENE 2020-8-11
Hi Lena Frey. I got the same issue as you, and i found that "help m_grid" shows wrong way to use "xtick" option, It's very annoying. Or it works depending on MATLAB version you use, i don't know.
help proposes to use "xtick" option 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