Legend with different text color and Latex Interpreter

조회 수: 53 (최근 30일)
K3iTH
K3iTH 2020년 3월 24일
편집: dpb 2020년 3월 25일
Hi everyone,
I have a legend with different text color, and I wanted to apply Latex markup.
I have the code shown below and it is working. However, when I set the Interpreter to be Latex, it doesn't work at all.
Is there any mistake I have made?
l=legend('\color[rgb]{0.9 0.9 0.9} S=0.8, AR=0.25');
%% set the Interpreter to be Latex
set(l, 'Interpreter', 'latex')
  댓글 수: 1
dpb
dpb 2020년 3월 24일
From the doc on 'Interpreter' property linked to from text documetation:
LaTeX Markup
To use LaTeX markup, set the Interpreter property to 'latex'. Use dollar symbols around the text, for example, use '$\int_1^{20} x^2 dx$' for inline mode or '$$\int_1^{20} x^2 dx$$' for display mode.
The displayed text uses the default LaTeX font style. The FontName, FontWeight, and FontAngle properties do not have an effect. To change the font style, use LaTeX markup.

댓글을 달려면 로그인하십시오.

답변 (1개)

Stijn Haenen
Stijn Haenen 2020년 3월 24일
편집: Stijn Haenen 2020년 3월 24일
I dont think it is possible to change the color with the latex interpreter. It can be used to make text bold for example and insert symbols. i would change the color like this:
legend('\textbf{test}','TextColor',[0 1 0],'Interpreter','latex');
  댓글 수: 2
K3iTH
K3iTH 2020년 3월 24일
Hi there,
This is working even without
\textbf
However, my legend has 9 inputs and 6 of them need to be in grey and the rest will be in black color. That is not working anymore if I input more than 1.
Thanks
dpb
dpb 2020년 3월 24일
편집: dpb 2020년 3월 25일
"... legend has 9 inputs and 6 of them need to be in grey and the rest will be in black color. That is not working ... if I input more than 1."
'TextColor' is a single global property for the legend handle, there isn't the facility to have multiple values for a single property.
And, there's no facility to add more than a single legend to a figure/axes so you're stuck on that one.
An alternative would be to use annotation or text objects to write the strings, not legend

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by