MATLAB: Plotting (and saving) a figure with a black background

backgroundblackcolorfigureplotpngsavesubplot

Hi again,
I have another plotting question; I have 4 subplots and I want one of them to have a black background. Since I only want one to have the black background I can't use colordef.
I have tried:
set(subplot(vertical,horizontal,figure_name),'Color','k')
and:
set(gca,'color','black')
These both work to colour the subplot in the figure window but when I save the figure (as a .png) the saved subplot has a white background. I have also tried plotting a massive black patch that covers the plot area – but this also gets missed or overwritten when saving the figure!
If there are any other commands/ways to change the background colour I would love to know them.
As always any help is greatly appreciated.
Rod.

Best Answer

You accepted the wrong answer. There is a way to do it. this works just fine:
subplot(2,2,1);
subplot(2,2,2);
subplot(2,2,3);
subplot(2,2,4);
set(gca,'color','black')
export_fig('yourfigure.png');
export_fig() is available here: http://www.mathworks.com/matlabcentral/fileexchange/ It's the most downloaded File Exchange submission ever, for a reason.