title: Changing matlab background colors
body: <p>This code </p>
  
  <pre><code>  1 function makegraph(A,B)
    2 results=load(A);
    3 time = results(:,3) - 1238370000;
    4 firstTimeIndex = find(time &gt;= (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
  </code></pre>
  
  <p>Saves this graph in the filename 'B'...<img src="https://i.stack.imgur.com/v2jEl.jpg" alt="enter image description here"></p>
  
  <p>It works fine, but I'd like to put it in a different context, for which I need it to have a black background...</p>
  
  <p>I have tried setting </p>
  
  <pre><code>set(gca,'color',[1 1 0])
  set(gcf,'color',[1 1 0])
  </code></pre>
  
  <p>as described by <a href="https://stackoverflow.com/questions/10291651/setting-the-background-color-of-a-plot-in-matlab-using-the-command-line">Setting the background color of a plot in MATLAB using the command line?</a></p>
  
  <p>and I've tried </p>
  
  <pre><code>whitebg(1,'k')
  </code></pre>
  
  <p>...and I'm getting nowhere -particualarly because sometimes when I try and play around with some of </p>
  
  <p>set(gca,'color','black')
      set(gcf,'color','black') settings, some of my plots disappear. </p>
  
  <p>I'm deeply confused.. could someone tell me why the accepted answer at <a href="https://stackoverflow.com/questions/10291651/setting-the-background-color-of-a-plot-in-matlab-using-the-command-line">Setting the background color of a plot in MATLAB using the command line?</a> isn't working here...?</p>