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
Walter Roberson
Walter Roberson 2019 年 7 月 21 日
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 ExchangeGravitation, 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