LaTeX in MATLAB®
How to add LaTeX to MATLAB® plots with Plotly.
Basic example
fib = zeros(1, 12);
for i = 1:12
fib(i) = (((1+sqrt(5))/2)^i - ((1-sqrt(5))/2)^i)/sqrt(5);
end
figure
plot(1:12, fib, 'k^-')
title('Fibonacci Numbers from 1-12')
xlabel('n')
ylabel('F_n')
eqtext = '$$F_n={1 \over \sqrt{5}}';
eqtext = [eqtext '\left[\left({1+\sqrt{5}\over 2}\right)^n -'];
eqtext = [eqtext '\left({1-\sqrt{5}\over 2}\right)^n\right]$$'];
text(0.5, 125, eqtext, 'Interpreter', 'Latex', 'FontSize', 12, 'Color', 'k')
fig2plotly(gcf);
LaTeX Typesetting
trace1 = struct(...
'x', [1, 2, 3, 4], ...
'y', [1, 4, 9, 16], ...
'name', '$\alpha_{1c} = 352 \pm 11 \text{ km s}^{-1}$', ...
'type', 'scatter');
trace2 = struct(...
'x', [1, 2, 3, 4], ...
'y', [0.5, 2, 4.5, 8], ...
'name', '$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$', ...
'type', 'scatter');
data = {trace1, trace2};
layout = struct(...
'xaxis', struct('title', '$\sqrt{(n_\text{c}(t|{T_\text{early}}))}$'), ...
'yaxis', struct('title', '$d, r \text{ (solar radius)}$'));
plotly(data, struct('layout', layout));