different colors for the title

46 次查看(过去 30 天)
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');

更多回答(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