LaTeX interpreter on a legend
160 ビュー (過去 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!