How to change the default color order for all figures?

113 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Stephen23
Stephen23 el 14 de Sept. de 2023
Editada: Stephen23 el 14 de Sept. de 2023
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 comentarios
Roy Goodman
Roy Goodman el 18 de En. de 2024
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 el 18 de En. de 2024
Editada: Stephen23 el 18 de En. de 2024
"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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by