フィルターのクリア

How to set different colors for the text in a legend ?

110 ビュー (過去 30 日間)
naman
naman 2016 年 8 月 30 日
コメント済み: Chibuzo Nnonyelu 2018 年 12 月 18 日
Hi
I am using MATLAB 2015. I followed the post >https://se.mathworks.com/matlabcentral/newsreader/view_thread/73336> to set different colors for the different text but still it does not work. According to the link, my hText is empty and h is 1 x 1 legend, but it has more than 1 string. Whats the possible solution here ?

回答 (1 件)

George
George 2016 年 8 月 30 日
編集済み: George 2016 年 9 月 1 日
Use TeX formatting to set the colors.
x = -pi:pi/20:pi;
y1 = sin(x);
y2 = cos(x);
plot(x,y1,'-ro',x,y2,'-.b');
l = legend('\color{red} sin(x)','\color{blue} cos(x)');
You can also set the color using RGB triplets with
\color[rgb]{0,0.5,0}
  5 件のコメント
George
George 2016 年 9 月 1 日
編集済み: George 2016 年 9 月 1 日
\color[rgb]{0,0.5,0}
It's on the doc page under TeX markup.
Chibuzo Nnonyelu
Chibuzo Nnonyelu 2018 年 12 月 18 日
How can this be done with/under LaTex interpreter?

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

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by