I am running Matlab R2010A on OS X 10.7.5
I have a simple matlab plot and would like to use LaTeX commands in the axis and legend. However setting:
set(0, 'defaultTextInterpreter', 'latex');
Has zero effect, and results in a TeX warning that my tex commands can not be parsed. If I open plot tools of this plot, the default interpreter is set to 'TeX'. Manually setting this to 'LaTeX' obviously fixes this, but I can't do this for hundreds of plots.
Now, if I retrieve the default interpreter via the Matlab prompt, i.e
get(0,'DefaultTextInterpreter')
It says 'LaTeX', but again, when I look in the properties of the figure via the plot tools menu, the interpreter remains set to 'TeX'.
Complete plotting code:
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);
This works for me (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
I can change 'defaultTextInterpreter'
set(0, 'defaultTextInterpreter', 'latex');
xlabel('$$P_{fa}$$', 'fontsize', fontSize);
ylabel('$$P_{m}$$', 'fontsize', fontSize);
legend({'$$\textbf{K}_{zz}$$'},'interpreter', 'latex','fontsize',fontSize)
obtaining the better version
If I remove 'interpreter', 'latex'
from the legend
call, I have bad results, though:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With