Changing default 'g' color

조회 수: 7 (최근 30일)
Jack
Jack 2013년 12월 18일
편집: José-Luis 2013년 12월 18일
I would like to change the default 'g' color for plots. It's too bright for presentations, so I would like set 'g' = [0 0.5 0] rather than [0 1 0] of the default. I do not want to change all the color though; the default colors for 'b' and 'r' are fine as is.
Is there a way to change the default of 'g' permanently or at the start of a function so that I do not have to manually enter "plot(... 'Color', [0 0.5 0]...)" every time? Ideally, I would just use "plot(t,x,'g')" to create a green colored line.
Thanks, Jack

채택된 답변

José-Luis
José-Luis 2013년 12월 18일
편집: José-Luis 2013년 12월 18일
I don't think it is a good idea to mess around with system defaults, especially if someone else is going to be using your machine. Maybe this is my cop-out way of saying that I don't know if this can even be done, but I'll propose a workaround anyway.
Say you plot some stuff:
figure(1)
plot(rand(10,2),'g')
figure(2)
plot(rand(10,6),'g')
hold on
plot(rand(10,5));
Then you could change the green stuff to your own version of green by just adding this line:
set(findobj('color','g'),'Color',[0 0.5 0]);

추가 답변 (2개)

Image Analyst
Image Analyst 2013년 12월 18일
See my demo on changing the default plot colors, attached in blue. You'd have to run this code each time as it is applied to a particular axes. I don't know if there is a way to have it changed for all axes that you might ever create now and in future runs of MATLAB.

Walter Roberson
Walter Roberson 2013년 12월 18일
The named colors such as 'g' have built-in values that there is no documented way of changing.
When no particular color is specified for a line, the ColorOrder axis property is followed. Image Analyst's demo shows how to change and experiment with it for a given axis. You can also set the root property DefaultColorOrder to specific RGB values. But note that these are distinct from the named colors.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by