TeX (LaTeX math mode) symbols in legends and labels in MATLAB figures
이전 댓글 표시
I am plotting some data which includes estimates of some parameters. I want to describe the estimates by using \hat on the parameter symbols. This I have to do in legends and axis labels fields. I could not fix this matter despite some experiments using information from MATLAB help. Any idea, please to fix this problem. I really appreciate help on this matter which will improve the look of my presentation. Shah
채택된 답변
추가 답변 (6개)
Mikhail Smirnov
2017년 2월 10일
You can do like this
plot(1:10);
leg1 = legend('$\bar{x}$','$\tilde{x}$','$\hat{x}$');
set(leg1,'Interpreter','latex');
set(leg1,'FontSize',17);

works well
댓글 수: 4
Walter Roberson
2017년 9월 1일
Ahmad Alsharif comments to Mikhail Smirnov:
This helped me in creating multi line legend with latex as interpreter
Thomas Gillet
2017년 12월 17일
Hello Everyone,
When I use Latex interpreter, I am not able to change the font of the legend as you mentionned with set(leg1,'FontSize',17); Have you any idea ? Thank's, Thomas
Mario
2023년 4월 17일
Unfortunately this doesn't work for me.
I am tried using annotations and legends to write v_{mean on} as v_on to save figure space.
I tried several things:
lgd = legend{'on', 'off', '$$\bar{\itv}$$_{on}', 'v_{mean off}'}
lgd = legend{'on', 'off', '$\bar{\itv}$_{on}', 'v_{mean off}'}
lgd = legend{'on', 'off', '$\bar{v}$_{on}', 'v_{mean off}'}
lgd = legend{'on', 'off', ['$\bar{v}$','_{on}'], 'v_{mean off}'}
or
lgd = legend{'on', 'off', '$$\overline{\itv}$$_{on}', 'v_{mean off}'}
lgd = legend{'on', 'off', '$\overline{\itv}$_{on}', 'v_{mean off}'}
lgd = legend{'on', 'off', '$\overline{v}$_{on}', 'v_{mean off}'}
lgd = legend{'on', 'off', ['$\overline{\itv}$','_{on}'], 'v_{mean off}'}
won't work.
It would just add the $$\overline... to the legend text.
I tried both latex and tex interpreter.
I am using MATLAB v 2018b
I figured it out:
lgd = legend('on','off', '$\overline{v}_{on}$', '$\overline{v}_{off}$')
But now my font is not Calibri anymore. it's rather looking like Times New Roman or sth.
set(lgd, 'interpreter', 'latex', 'FontName', 'Calibri')
won't help :(
is there a problem with Calibri + Latex?
Frederik van der Walt
2012년 4월 4일
편집: KSSV
2022년 5월 26일
l= legend(['$\hat{\psi}$']);
set(l,'Interpreter','Latex');
Jordan Brel Ngako Kadji
2020년 5월 7일
0 개 추천
Once I had this problem, I was writing in German and because the german letter 'ä' was not recognised all the latex commands were ignored.
댓글 수: 1
Rostislav Lebedev
2022년 3월 16일
Try this
title('Verkehrstr\"ager', 'Interpreter', 'latex');
Richard Ulbricht
2022년 12월 13일
Put this in front of your plotting commands, if you want it for all plots:
set(groot,'defaultLegendInterpreter','latex');
댓글 수: 1
Yan Gao
2023년 7월 4일
This is the best solution! Thanks, Richard!
카테고리
도움말 센터 및 File Exchange에서 RF Propagation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

