different colors for the title
    27 次查看(过去 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.
0 个评论
采纳的回答
  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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

