我在OS X 10.7.5上运行Matlab R2010A
我有一个简单的matlab图,想在轴和图例中使用LaTeX命令.但是设置:
set(0, 'defaultTextInterpreter', 'latex');
没有效果,并导致TeX警告我的tex命令无法解析.如果我打开此绘图的绘图工具,则默认解释器将设置为"TeX".手动将其设置为'LaTeX'显然可以解决这个问题,但我不能为数百个图表做到这一点.
现在,如果我通过Matlab提示检索默认解释器,即
get(0,'DefaultTextInterpreter')
它说'LaTeX',但是当我通过绘图工具菜单查看图的属性时,解释器仍然设置为'TeX'.
完整的绘图代码:
figure
f = 'somefile.eps'
set(0, 'defaultTextInterpreter', 'latex');
ms = 8;
fontSize = 18;
loglog(p_m_sip, p_fa_sip, 'ko-.', 'LineWidth', 2, 'MarkerSize', ms); hold on;
xlabel('$P_{fa}$', 'fontsize', fontSize);
ylabel('$P_{m}$', 'fontsize', fontSize);
legend('$\textbf{K}_{zz}$', 'Location', 'Best');
set(gca, 'XMinorTick', 'on', 'YMinorTick', 'on', 'YGrid', 'on', 'XGrid', 'on');
print('-depsc2', f);
Run Code Online (Sandbox Code Playgroud)
Aco*_*rbe 14
这对我有用(R2011B)
figure
ms = 8;
fontSize = 18;
xx = 0:.1:1;
plot(xx,sin(xx))
xlabel('P_{fa}', 'fontsize', fontSize); %No need for latex explicitly (Tex is enabled by default)
ylabel('P_{m}', 'fontsize', fontSize);
legend({'$$\textbf{K}_{zz}$$'}, 'interpreter', 'latex','fontsize',fontSize); %Explicit latex
%REM: legend needs a cell
Run Code Online (Sandbox Code Playgroud)

我可以改变 'defaultTextInterpreter'
set(0, 'defaultTextInterpreter', 'latex');
xlabel('$$P_{fa}$$', 'fontsize', fontSize);
ylabel('$$P_{m}$$', 'fontsize', fontSize);
legend({'$$\textbf{K}_{zz}$$'},'interpreter', 'latex','fontsize',fontSize)
Run Code Online (Sandbox Code Playgroud)
获得更好的版本

如果我'interpreter', 'latex'从legend通话中删除,我的结果不好,但是:

| 归档时间: |
|
| 查看次数: |
21697 次 |
| 最近记录: |