フィルターのクリア

Assigning Color to Plot of Same Variable?

2 ビュー (過去 30 日間)
Brandon Luciano
Brandon Luciano 2018 年 3 月 19 日
コメント済み: Brandon Luciano 2018 年 3 月 20 日
So I am plotting the same variable 3 times within one figure that's parameters change with simulink. It produces 3 lines but the problem is, the 3 lines are the same color even though I specify each of the plots to be different linewidth, color and legend. It produces the very last specific color values.
I tried the following
plot(t,x, 'Color', 'Black', 'Linewidth', 2);
legend('Black');
hold on;
plot(t,x, 'Color', 'Cyan', 'Linewidth', 2);
legend('Cyan');
hold on;
plot(t,x, 'Color', 'Blue', 'Linewidth', 2);
legend('Blue');
All the lines on the graph show up as Blue even though I specified different colors/legend for each of the lines.

採用された回答

Image Analyst
Image Analyst 2018 年 3 月 19 日
Try this
plot(t, x, 'k-', 'LineWidth', 2);
hold on;
plot(t, x, 'c-', 'LineWidth', 2);
plot(t, x, 'b-', 'LineWidth', 2);
legend('Black', 'Cyan', 'Blue');
  5 件のコメント
Image Analyst
Image Analyst 2018 年 3 月 20 日
You can set the default color order if you want so the colors are not "random". See attached demo.
Brandon Luciano
Brandon Luciano 2018 年 3 月 20 日
Thank you. This was helpful.

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

その他の回答 (0 件)

カテゴリ

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