Matlab title with different colors on the string

How do I specify different font colors on the same string using the TEXT, TITLE, XLABEL, YLABEL, or ZLABEL commands in Matlab 8.2(R2013b)?
A previous solution for ver 2009a suggested using this as an example:
title(['\fontsize{16}black {\color{magenta}magenta '...
'\color[rgb]{0 .5 .5}teal \color{red}red} black again'])
...which does not work anymore. Any help will be appreciated.

 採用された回答

Chad Greene
Chad Greene 2015 年 7 月 8 日

4 投票

I just tried your suggested solution and it works on 2012b and 2014b. Is it an issue with the interpreter? Try specifying
title(['\fontsize{16}black {\color{magenta}magenta ','\color[rgb]{0 .5 .5}teal \color{red}red} black again'],'interpreter','tex')

2 件のコメント

Hassan
Hassan 2017 年 11 月 29 日
Dear Chad, Would you please write an example of how I can put a variable containing the three-element vector instead of writing it manually? I tried to add it using the num2str function with no success. Thanks, HM
Walter Roberson
Walter Roberson 2018 年 2 月 8 日
title( sprintf('%s%s{%f %f %f}', '\fontsize{16}', '\color[rgb]', RGB_vector), 'interpreter, 'tex')

サインインしてコメントする。

その他の回答 (1 件)

Simona Cianci
Simona Cianci 2018 年 2 月 8 日
編集済み: Walter Roberson 2018 年 2 月 8 日

0 投票

The solution with the interpreter does not work with suptitle, any solutions? .
suptitle([sprintf('FREQUENZE STRATEGIE\n'),'{ \color{blue} Caviglia',' \color{red}Anca',' \color[rgb]{0 .6 0}Passo',' \color[rgb]{.25 .25 .25} EC', '\color{w} EO}'],'interpreter','tex');
Tnks

1 件のコメント

Walter Roberson
Walter Roberson 2018 年 2 月 8 日
suptitle is a helper function for yeastdemo of the Bioinformatics toolbox. Is that what you are using, or are you using something from the File Exchange?

サインインしてコメントする。

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by