简体   繁体   中英

Use Latex in Matlab legend?

My matlab does not accept my latex . For example if I use legend('b^{+6}\\rightarrow b^{+7}') , it does not show me the arrow, How I can solve the problem?

Try with Latex interpreter, something like

legend({'$b^{+6}\rightarrow b^{+7}$'}, 'interpreter', 'latex')

Tested under R2012a:

在此处输入图片说明

For xlabel and ylabel , simply use something like:

xlabel( ' $\Delta t$ [ sec ] ','Interpreter','latex')

For some reason, Matlab has more difficulty with legends; you have to set the interpreter after the legend has been created:

legend_handle = legend('$b^{+6}\rightarrow b^{+7}$');
set(legend_handle,'Interpreter','latex')

In my case I had to set the latex interpreter after the legend command:

l = legend({'$b^{+6}\rightarrow b^{+7}$'})
set(l, 'Interpreter', 'Latex');

This worked in Matlab R2016b

if the comand... l = legend({'$b^{+6}\\rightarrow b^{+7}$'}) set(l, 'Interpreter', 'Latex'); dosn't work. Try to put "hold on" after the "set" instruction".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM