different colors for the title

49 visualizzazioni (ultimi 30 giorni)
MINA
MINA il 11 Mar 2020
Commentato: MINA il 11 Mar 2020
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.

Risposta accettata

Ameer Hamza
Ameer Hamza il 11 Mar 2020
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');

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by