Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

TeX (LaTeX math mode) symbols in legends and labels in MATLAB figures

Asked by Shah on 22 Nov 2011
Latest activity Edited by Matthew Simoneau on 30 May 2014

I am plotting some data which includes estimates of some parameters. I want to describe the estimates by using \hat on the parameter symbols. This I have o do in legends and axis labels fields. I could not fix this matter despite some experiments using information from MATLAB help. Any idea, please to fix this problem.

I really appreciate help on this matter which will improve the look of my presentation.

Shah

0 Comments

Shah

Tags

Products

No products are associated with this question.

4 Answers

Answer by Frederik van der Walt on 4 Apr 2012

l= legend(['$\hat{\psi}$']);

set(l,'Interpreter','Latex');

0 Comments

Frederik van der Walt
Answer by Steven on 22 Nov 2011

Try with Latex interpreter, something like

    title(['$ latex $'],'interpreter','latex')

1 Comment

Shah on 22 Nov 2011

Thanks Steven but its not working here. I am using MATLAB 7.9.0.

I wrote legend(['$\hat{\psi}$'],'interpreter','latex') but got a warning: Unable to interpret TeX string '$\hat{\psi}$'interpreterlatex'. Same appear in the legend field.

Steven
Answer by Shah on 23 Nov 2011

......... Its done! Actually, the default interpreter in MATLAB for legend is 'tex', I guess. It is not changed from the code line. What I had to do was to right click on the legend in the figure window and then changed the 'interpreter' from 'tex' to 'latex'. This action changed the latex statement in the legend field to Math mode.

Cheers Shah

0 Comments

Shah
Answer by Matthew Simoneau on 30 May 2014

To use the full LaTeX interpreter, you can specify it as a parameter:

title('$\hat{\psi}$','Interpreter','latex')

Note that for legend, you need to use pass in you labels as a cell array to distinguish them from the parameters:

plot(1:10)
legend({'$\hat{\psi}$'},'Interpreter','latex')

0 Comments

Matthew Simoneau

Contact us