How to change the default color order for all figures?

134 ビュー (過去 30 日間)
Dr. Fernando Viadero-Monasterio
Dr. Fernando Viadero-Monasterio 2023 年 9 月 14 日
編集済み: Stephen23 2024 年 1 月 18 日
Hello everyone,
I'd like to change the default color order for every figure in a script, without needing to do it plot by plot.
As an example, we can change other default properties for every figure with
set(0, 'DefaultaxesFontSize', desiredFontSize)
set(0, 'defaultLineLineWidth', desiredLineLineWidth)
Fyi, you can reset all this user changes by
reset(0)
However, I don't know if there is an option to do this for the property colororder.
I know that I could change the color order plot by plot, as example
newcolors = [0.83 0.14 0.14
1.00 0.54 0.00
0.47 0.25 0.80
0.25 0.80 0.54];
colororder(newcolors)
However, I like my code as simple and short as possible!
Thanks in advance

採用された回答

Stephen23
Stephen23 2023 年 9 月 14 日
編集済み: Stephen23 2023 年 9 月 14 日
M = rand(5,7);
plot(M)
newcolors = [0.83,0.14,0.14; 1,0.54,0; 0.47,0.25,0.8; 0.25,0.8,0.54];
set(groot, "defaultaxescolororder", newcolors)
plot(M)
Hint: use the MATLAB documentation. Scroll to the bottom of the COLORORDER page and you will find these links:
which clearly states that the color order is an axes property. And this link to all axes properties:
The properties page includes the color order:
You might also find this useful information:
  3 件のコメント
Roy Goodman
Roy Goodman 2024 年 1 月 18 日
In a similar vein, I'd like to start using the new builtin colororder gem12 by default.
Neither of the following two command work:
set(groot, "defaultaxescolororder",gem12)
set(groot, "defaultaxescolororder","gem12")
What's the right way to do this?
Stephen23
Stephen23 2024 年 1 月 18 日
編集済み: Stephen23 2024 年 1 月 18 日
"What's the right way to do this?"
Exactly the same way, by supplying the required colors to SET:
map = orderedcolors("gem12");
set(groot, "defaultaxescolororder",map)
M = rand(5,12);
plot(M)
Search the help for "GEM12" and this is the very first page that is returned:
You also find it linked at the bottom of the COLORORDER page.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by