Insert solar symbol on plot axis

Hello everyone, how can i insert the solar symbol on my plot axis .tried the following and it doesnt work solar = char(9737) ylabel( ['10^{-6} M_',solar, 'Year^{-1}'], 'FontSize',14,'FontWeight','bold'):it gives “?”instead of solar symbol.help

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 21일
편집: KALYAN ACHARJYA 2019년 7월 21일

0 개 추천

Is this you are looking for?
I tried with your code
solar=char(9737)
ylabel(['10^{-6} M_',solar, 'Year^{-1}'], 'FontSize',14,'FontWeight','bold');

댓글 수: 10

charles aouad
charles aouad 2019년 7월 21일
thank you for your prompt answermy code is exactly as follows, it doesnt work for me :( :
set(get(sub1,'Ylabel'),'String','Rotation velocity [km/s]');
set(get(sub2,'Ylabel'),'String','[km/s/Kpc]');
solar = char(9737);
set(get(sub3,'Ylabel'),'String','\Sigma{sfr}/\Sigmasfr_{total} [M ,solar, Kpc^{-2}Year^{-1}]');
set(get(sub3,'Xlabel'),'String','Galactocentric Radius [Kpc]');
Walter Roberson
Walter Roberson 2019년 7월 21일
Is there somewhere in your code that is setting latex interpreter for the labels? Latex interpreter cannot use Unicode characters. Tex interpreter can use Unicode.
charles aouad
charles aouad 2019년 7월 21일
thank you walter. no there is nowhere in my code that sets latex as interpreter for the labels can you show me how to do that? ?in that case i can just use the usual \odot ?
thank you in advance
Walter Roberson
Walter Roberson 2019년 7월 21일
Could you remind us which MATLAB version are you using?
charles aouad
charles aouad 2019년 7월 21일
2018a
Could you go to the command line and try those two lines,
solar=char(9737)
ylabel(['10^{-6} M_',solar, 'Year^{-1}'], 'FontSize',14,'FontWeight','bold');
just by themselves?
solar = char(9737);
set(get(sub3,'Ylabel'),'String','\Sigma{sfr}/\Sigmasfr_{total} [M ,solar, Kpc^{-2}Year^{-1}]');
Look more closely at that. Your quoted strings are
'Ylabel'
'String'
'\Sigma{sfr}/\Sigmasfr_{total} [M ,solar, Kpc^{-2}Year^{-1}]'
Notice that in that third one, solar is within the quoted string, so it is going to be taken literally rather than the assigned value being used.
['\Sigma{sfr}/\Sigmasfr_{total} [M ,', solar, ',Kpc^{-2}Year^{-1}]']
charles aouad
charles aouad 2019년 7월 22일
hi walter, thank you for your reply
i tried what you suggested and the solar symbol shows now but i have another problem
the y labels on subplot 1 and 2 are not showing (line code 76 and 78)
i have attached below a screen shot of my code and the plot generated, i dont know why it refuses to show the y labels for the first 2 subplots while it shows it for the last subplot, am i missing something obvious?screen shot 1 matlab code.jpg
screen shot 1 matlab code.jpg
Walter Roberson
Walter Roberson 2019년 7월 23일
You ovewrite the label of line 76 with the label at line 78, and overwrite the label of line 78 with the label at line 81.
You should probably be recording axes handles and passing them to your various plotting calls.
charles aouad
charles aouad 2019년 7월 24일
thank you very much walter for your help.
is there any way where i can specify that this label will gof or this sub plot without the handles?
like when i create the subplot i can immdiately label the axes?
why the command set('sub1','ylabel','velocity in km/s') doesnt work?
Walter Roberson
Walter Roberson 2019년 7월 24일
I do not know what sub1 is in this context.
You need to be careful with calling xlabel() or ylabel() just after your subplot() call, in that if you do not do a hold on before you plot() then plot() will probably erase the labels.

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

카테고리

도움말 센터File Exchange에서 Gravitation, Cosmology & Astrophysics에 대해 자세히 알아보기

질문:

2019년 7월 21일

댓글:

2019년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by