Different colors for different text in a single textbox

조회 수: 38 (최근 30일)
Mark Stone
Mark Stone 2022년 12월 24일
댓글: Walter Roberson 2025년 5월 28일
Is it possible to have different colors for different text in a single text box?
For example,
1st line of text is black
2nd line of text is blue
3rd line of text is red.

채택된 답변

Voss
Voss 2022년 12월 24일
str = { ...
'\color{black}1st line of text', ...
'\color{blue}2nd line of text', ...
'\color{red}3rd line of text'};
t = text(0.5,0.5,str);
  댓글 수: 4
Keqin Xu
Keqin Xu 2025년 5월 28일
What if I want to use more colors that don't even have a name?
Walter Roberson
Walter Roberson 2025년 5월 28일
str = '\color[rgb]{0.1,0.8,0.95} Sample rgb text';
text(0.5,0.5,str)
Note that for this to work, the text() Interpreter property must be 'tex' (which is the default)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by