Color of plots when there are multiple plots

25 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2018 年 6 月 8 日
コメント済み: Ameer Hamza 2018 年 6 月 9 日
I draw multiple plots using hold on
Plot61=plot(Date,A,'LineWidth',1.2)
hold on
Plot62=plot(Date,B,'LineWidth',1.2)
hold on
Plot63=plot(Date,C,'LineWidth',1.2)
hold on
legend([Plot61, Plot62, Plot63], 'A','B','C')
In this case Matlab automatically assign colors for these three plots. But it turns out that they are not easy to distinguish. But I do not want to specify colors for each plot (because actually there are like 10 plots.) What are the steps to change the default for these automatic assignments of colors to plots?
  4 件のコメント
Ameer Hamza
Ameer Hamza 2018 年 6 月 8 日
Just for information, it is possible to specify the color order, with MATLAB assign color, manually by using ColorOrder property of the axes object.
Walter Roberson
Walter Roberson 2018 年 6 月 8 日
set(gca, 'ColorOrder', parula(10))
parula has been designed to try to make the colors visually distinctive.

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

採用された回答

Paolo
Paolo 2018 年 6 月 8 日
Since you specified that you do not wish to specify the color manually, you can use:
plot(Date,A,'Color',rand([1 3]))
To create a random rgb triplet for each plot.

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2018 年 6 月 8 日
Although you can change the color order as I specified in the comment but for your case, the easier solution is to use the Color property of the line to manually specify the color. For example
Plot61=plot(Date,A,'LineWidth',1.2,'Color',[0.4 0.2 0.6])
The vector [0.4 0.2 0.6] represents a rgb triplet and you can change its value to change the color of the line. Note that each value in the rgb triplet vector can vary from 0 to 1.
  3 件のコメント
Paolo
Paolo 2018 年 6 月 8 日
Check the answer below @alpedhuez.
Ameer Hamza
Ameer Hamza 2018 年 6 月 9 日
@alpedhuez, you can refer to Paolo to randomly generate rgb triplets, although there is a chance that the random triplets might generate visually similar colors. You might also want to try parula() as suggested by Walter in the comment. Just to be clear, you need to add that line before the plot() commands.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by