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

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 21 de Jul. de 2019
Editada: KALYAN ACHARJYA el 21 de Jul. de 2019
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 comentarios

charles aouad
charles aouad el 21 de Jul. de 2019
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 el 21 de Jul. de 2019
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 el 21 de Jul. de 2019
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 el 21 de Jul. de 2019
Could you remind us which MATLAB version are you using?
charles aouad
charles aouad el 21 de Jul. de 2019
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 el 22 de Jul. de 2019
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 el 23 de Jul. de 2019
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 el 24 de Jul. de 2019
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 el 24 de Jul. de 2019
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Gravitation, Cosmology & Astrophysics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 21 de Jul. de 2019

Comentada:

el 24 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by