How to change the default color order for all figures?
55 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dr. Fernando Viadero-Monasterio
am 14 Sep. 2023
Bearbeitet: Stephen23
am 18 Jan. 2024
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
0 Kommentare
Akzeptierte Antwort
Stephen23
am 14 Sep. 2023
Bearbeitet: Stephen23
am 14 Sep. 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 Kommentare
Roy Goodman
am 18 Jan. 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
am 18 Jan. 2024
Bearbeitet: Stephen23
am 18 Jan. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!