LaTeX interpreter on a legend
조회 수: 141 (최근 30일)
이전 댓글 표시
I want the greek letter on my legend to look like as it does in LaTeX. Here is the code:
clc;
clear all;
phi=[1/2,1/3,1/4];
l=-0.1:.05:.1;
p = @(x,phi,l) 1/3.*(exp(x.^(phi))-1)./(exp(x.^(phi))+1) + l;
x=linspace(0,.2,101);
for k2 = 1:length(l)
figure(k2)
legendCounter = 1;
for k1 = 1:length(phi)
pValues = p(x,phi(k1),l(k2));
if any(pValues >= 0)
plot(x, pValues)
drawnow;
hold all
ar{legendCounter} = sprintf('{\\it\\phi_{state} =}%s',rats(phi(k1),3));
legendCounter = legendCounter + 1;
end
end
grid
axis([0 .21 0 .25])
hold off
legend(ar, 'Location','best')
plot2svg(['a=',num2str(k2),'.svg'])
end
Even though the greek letter looks fine on the matlab screen, when I see the resulting .svg file, it looks different. Is there any way to adjust this?
댓글 수: 0
답변 (1개)
Andrew Newell
2015년 3월 4일
편집: Andrew Newell
2015년 3월 4일
You could try setting the interpreter to LaTeX:
legend(ar, 'Location','best','Interpreter','latex')
For this to work, you'll have to reformat the equation so there are dollar signs around it:
ar{legendCounter} = sprintf('$\\phi_\\mathrm{state} =%s$',rats(phi(k1),3));
While I was at it, I made the subscript into Roman characters because that is better style when the subscript is not a variable.
참고 항목
카테고리
Help Center 및 File Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!