필터 지우기
필터 지우기

How to change the default color order for all figures?

조회 수: 108 (최근 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 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