different colors for the title

조회 수: 49 (최근 30일)
MINA
MINA 2020년 3월 11일
댓글: MINA 2020년 3월 11일
I want to have different colors for different words in the title how can I do that? something like this:
p.col=[0.5 0.5 0.5; 0.1 0.1 0.1];
title({['\color[rgb]{p.color(1,:)','A= ',num2str(A),' \color[rgb] {p.color(2,:)} B= ,num2str(B))]},'fontsize',12)
I don't know how I can give a variable as a color specifier.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 3월 11일
You need to carefully compose the string. There are syntax error in your statement. Try
A = 1;
B = 1;
p.col=[1 0 0; 0 0 1];
t = title([ ...
'\color[rgb]{' sprintf('%1.2f,%1.2f,%1.2f', p.col(1,:)) '} A= ' num2str(A), ...
',\color[rgb]{' sprintf('%1.2f,%1.2f,%1.2f', p.col(2,:)) '} B= ' num2str(B)], ...
'fontsize',12, 'Interpreter', 'tex');
  댓글 수: 1
MINA
MINA 2020년 3월 11일
Thanks Ameer. It worked.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by