How to change the default color order for all figures?

104 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by