2013-08-07 3 views
2

이 코드변경 matlab에 배경 색상

1 function makegraph(A,B) 
    2 results=load(A); 
    3 time = results(:,3) - 1238370000; 
    4 firstTimeIndex = find(time >= (max(time) - 86400*7), 1); 
    5 results = results(max(1,firstTimeIndex-1):end, :);%Results now only containe s data from the last week 
    6 temp = results(:,3)-1238370000; 
    7 h=plot(temp,smooth(results(:,1)),':b','linewidth',2) 
    8 ylim([0 80]) 
    9 xlim([max(temp)-(86400*7),max(temp)-1]) 
10 set(gca,'color','black') 
11 set(gcf,'color','black') %get's rid of he axis alltogether 
12 hold on 
13 plot(temp, smooth(results(:,4)), 'r', 'linewidth', 2); 
14 plot(temp, smooth(results(:,5)), 'g', 'linewidth', 2); 
15 plot(temp, smooth(results(:,6)), 'm', 'linewidth', 2); 
16 xlim([max(temp)-(86400*7),max(temp)-1]) 
17 set(gca,'XTick',[1:86400:(max(temp))+1]) 
18 set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun']) 
19 print('-djpeg',B) 
20 hold off 

파일 이름을 'B'에서이 그래프를 저장합니다 ... enter image description here

그것은 잘 작동하지만 내가 다른 컨텍스트에 넣어 싶습니다, 있는 나는 내림차순으로

set(gca,'color',[1 1 0]) 
set(gcf,'color',[1 1 0]) 

설정을 시도

... 그것은 검은 배경이 필요 Setting the background color of a plot in MATLAB using the command line?

에 의해 ribed 내가

whitebg(1,'k') 

을 시도했습니다 ... 그리고 내가 갈 곳없는거야 -particualarly 때문에 가끔 시도하고

세트 (GCA들과 함께 놀 때, ' color ','black ') (gcf,'color ','black ') 설정을 적용하면 일부 플롯이 사라집니다.

나는 몹시 혼란 스럽다. 누군가 Setting the background color of a plot in MATLAB using the command line?에서 받아 들여지는 대답이 왜 여기에서 작동하지 않는지를 말해 줄 수 있었 을까? ...?

+0

B는 무엇입니까? matlab에 표시된 그림이나 인쇄 된 파일에만이 문제가 있습니까? – Molly

+0

gca \ gcf를 사용하는 대신 figure \ axes의 핸들을 직접 사용해보십시오. –

+0

@Molly B는 파일 이름입니다. - 편집 한 파일 - 인쇄 된 파일을보고 있습니다 ... 어떤 도움이 되었습니까? 그것... – Joe

답변

2

이 명령은 MATLAB 내에서 작업하고 있음을 밝혀, 그들은 단지 http://www.mathworks.co.uk/help/matlab/ref/print.html .... 기본적으로

에 따라 때문에 인쇄 파일을 작동하지 않는 한, MATLAB 인쇄의 그림 배경 색상을 변경 은 흰색으로 출력되지만 uicontrols의 색상은 변경되지 않습니다. 이 배경색을 설정 한 경우 (예 : GUI 장치의 회색과 일치하는 경우) 구성표를 유지하려면 InvertHardcopy를 off로 설정해야합니다. 명령을 사용하여 현재의 모습에 InvertHardcopy을 설정하려면 : 나는 세트 그래서 일단 ('오프', GCF, 'InvertHardcopy')

을 세트를 (GCF를 'InvertHardcopy', '오프'), 모든했다 복숭아 ... 특히 몰리에게 옳은 길에 나를 넣어 주셔서 감사합니다 ...