필터 지우기
필터 지우기

Moving map labels towards/away from axis

조회 수: 3 (최근 30일)
Jakob Weis
Jakob Weis 2020년 7월 29일
댓글: dpb 2020년 7월 29일
Hi,
I am trying to move the meridian/parallel labels in a map created with the mapping toolbox, i.e. increase the space between the labels and the map.
After a day of looking for an easy solution this is what I came up with:
%% MWE
figure(4);clf
axMap = worldmap([-60 -30],[160 190]);
setm(axMap,'mapprojection','eqdcylin')
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(axMap, land, 'FaceColor', [0.8 0.8 0.8])
setm(axMap,'FontSize', 20)
set(findobj(axMap.Children, 'Tag', 'MLabel'),'Units','points') % convert label position from 'data' to 'points'
mlabels = findobj(axMap.Children, 'Tag', 'MLabel'); % find all labels
labelpos = get(findobj(axMap.Children, 'Tag', 'MLabel'),'Position'); % get the positions of each label
for iL = 1 : length(labelpos) % loop over each label
labelpos{iL}(2) = labelpos{iL}(2) + 15; % add desired offset to the label position
set(mlabels(iL),'Position',labelpos{iL}) % set new label position
end
It works but seems like a horribly cumbersome approach to something that should be achievable in an easier way. I have looked through the map axis properties but couldn't find anything allowing me to change the label position relative to the axis. Note: mlabelparallel and plabelmeridian are not what I'm looking for.
Am I missing something?
Thank you!
  댓글 수: 1
dpb
dpb 2020년 7월 29일
" I have looked through the map axis properties but couldn't find anything allowing me to change the label position relative to the axis. ...Am I missing something?"
I don't have the toolbox to be able to test, but perhaps.
Try
saxMap=struct(axMap)
which will reveal all properties of the map axis object including those that are normally hidden. Oftentimes one can find the pieces of the object looking for that TMW didn't think were important for the end user.
Good luck "handle-diving"! :)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by