Reputation: 734
I am using octave (4.2.2) to make a figure with a black background.
clear;clf
%% circle
theta=linspace(0,2*pi,91);xc=cos(theta);yc=sin(theta);
fill(0.3*xc,0.3*yc,[0,0.5,0.5]);hold on
set(gca,'color',[0 0 0])
This script accomplishes that on the terminal, however if I print the figure using
print -dpng black.back.png
the image has a white background. If the set color command is changed to [1,1,1], both the figure displayed on the terminal and the printed image have a white background. Can anyone suggest a way to save an image with a black background to a file?
Upvotes: 1
Views: 3515
Reputation: 60444
This is a remnant from the early days (way before Windows came around) when the display background was black by default, but paper was white as it has always been. Figures have a property called InvertHardCopy
that is (still, after all these years) on by default. This property causes figures and axes to be printed with a white background.
Set it off for your expected behavior:
set(gcf,'InvertHardCopy','off')
See the MATLAB documentation. The Octave docs have a similar entry.
Upvotes: 2