Plot - Problems with background colour

I can change the background colour in plots with "whitebg", but those colour changes are not saved, when I save the figure as a .png with
saveas(gcf,'test.png')
What can I do?
This is a different question, but
set(gcf,'Color',[0.8 0.8 0.8])
doesn't change the background colour at all.

답변 (2개)

Jian Wei
Jian Wei 2014년 7월 22일

2 개 추천

Please execute the following command before you save the figure in the PNG format.
set(gcf, 'InvertHardcopy', 'off');
Then, you can save the plot as it is displayed.

댓글 수: 1

Aaron
Aaron 2014년 7월 22일
Thank you. It works. Now I only need to find a way to get rid of the dark grey frame "around" the figure.

댓글을 달려면 로그인하십시오.

Jian Wei
Jian Wei 2014년 7월 24일

0 개 추천

I want to clarify that you can execute the following command before you save the figure so that it can be saved as it is displayed.
set(gcf,'InvertHardcopy','off');
You can change the background color of your figure with the following command:
set(gcf,'Color',mybgcolor);
Here, mybgcolor is an RGB triple, a short name, or a long name of the predefined colors. For example, white is a predefined color whose RGB value is [1 1 1], short name is 'w', and long name is 'white', and pink is not a predefined color whose RGB value is [1 0.4 0.6]. Please refer to the following documentation for more information about the predefined colors. http://www.mathworks.com/help/releases/R2014a/matlab/ref/colorspec.html
Note that the default background color of a figure is gray whose RGB value is [0.8 0.8 0.8]. That's why setting the 'Color' to [0.8 0.8 0.8] does not change the background color.

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

질문:

2014년 7월 18일

답변:

2014년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by