Setting axis label with both LaTeX and text

93 visualizzazioni (ultimi 30 giorni)
I would like to set the axis label of a plot with the following text: "Distance (\lambda)"However, if I use:
>>xlabel('Distance (\lambda)')
the symbol is not identified. If I add a LaTeX interpreter, everything is treated as LaTeX. How do I achieve the desired formatting?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 22 Gen 2021
The symbol '\lambda' is not identified because it is not in a LaTeX interpreter. MATLAB only supports LaTeX markup when the interpreter property is set to 'latex.' You can use dollar symbols around the text if you want everything to be interpreted as LaTeX, but if you want to have both text and LaTeX in the same line, you need to separate the two parts into an array.
For example, in this specific case, you could use the line:
>>xlabel(['Distance ','$(\lambda)$'],'interpreter','latex')
By separating the text and LaTeX expressions in a char array, you can obtain the desired result. 

Più risposte (0)

Categorie

Scopri di più su Labels and Annotations in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by