Use Latex in Matlab legend?

ⅰ亾dé卋堺 提交于 2019-12-13 18:09:46

问题


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?


回答1:


Try with Latex interpreter, something like

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

Tested under R2012a:




回答2:


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')



回答3:


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




回答4:


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".



来源:https://stackoverflow.com/questions/22177564/use-latex-in-matlab-legend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!