MATLAB Answers

0

How can I change the degree symbol in axis tick label while using axesm function?

Md Atiqul Islam さんによって質問されました 2019 年 11 月 1 日
最新アクティビティ Md Atiqul Islam さんによって コメントされました 2019 年 11 月 5 日
Hello everyone,
You can see that the degree symbol in axis tick label (see Figure 1) is a bit higher position than normal. I tried to change it perfectly superscript (see Figure 2) taking handle of the function axesm but I can't. I did not find any option in the handle to change it. I used text function instead to prepare Figure 2. It is very time consuming to make degree symbol perfectly superscript using textm function. Some journal ask to make degree symbol perfectly superscript.

  4 件のコメント

Md Atiqul Islam 2019 年 11 月 4 日
@darova: I have corrected my question. Actually, I used text function instead of textm to format the tick label in Figure 2.
ax3=axes('Position',[0.10 0.10 0.05 0.815]);
set(ax3,'visible','off');
text(1.5,0.02,'20{\circ} N','FontName','Times New Roman','FontSize',12);
text(1.5,0.16,'21{\circ} N','FontName','Times New Roman','FontSize',12);
..................................
In axesm function, 'MeridianLabel' and 'ParallelLabel' are used to control the tick label. If I use these two properties to get degree symbols, I am getting the symbols as in Figure 1.
Is it possible to get degree symbol as like in Figure 2 using axesm function alone?
darova
2019 年 11 月 4 日
This code
plot(0,0)
title('90{\circ}')
% title(['90' char(176)])
text(1.5,0.02,'20{\circ} N','FontName','Times New Roman','FontSize',12);
text(1.5,0.16,'21{\circ} N','FontName','Times New Roman','FontSize',12);
xlim([-1 3])
Produces this
img1.png
Md Atiqul Islam 2019 年 11 月 4 日
@darova: could you please change the degree symbol in the tick labels of the following figure?
latlim = [-80 80];
lonlim = [100 -120];
figure
axesm('robinson','MapLatLimit',latlim,'MapLonLimit',lonlim,...
'Frame','on','Grid','on','MeridianLabel','on','ParallelLabel','on')
axis off
setm(gca,'MLabelLocation',60)
load coastlines
plotm(coastlat,coastlon)

サインイン to comment.

1 件の回答

回答者: darova
2019 年 11 月 4 日
 採用された回答

If you type something like:
h = get(gca,'children');
>> get(h(2),'string')
You will see that each label has "^" symbol
ans =
60^{\circ} N
So i just deleted that symbol:
h = get(gca,'children');
for i = 1:length(h)
if strcmp(get(h(i),'type'), 'text') % check if object is text
str = get(h(i),'string'); % get string
ix = strfind(str,'^'); % find "^" symbol
str(ix) = []; % delete the symbol
set(h(i),'string',str)
end
end
I have older MATLAB (v2013), maybe code will be a bit different with yours

  1 件のコメント

Md Atiqul Islam 2019 年 11 月 5 日
@darova: it works. thanks a lot for your help.

サインイン to comment.



Translated by