Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

Save MATLAB figure with different background color

Date: 2022-07-13 10:40:33

I want to print a MATLAB figure with a dark background and white labels. If I use the print or saveas command I lose somehow the colors. The plot symbols are dark again and the background is white. 

 

points = rand(100,3);
plot3(points(:,1),points(:,2),points(:,3),'*w')
grid on
set(gca,'Color',[0.5 0.5 0.5])
saveas(gcf,'test1','pdf')
saveas(gcf,'test2','png')
print(gcf,'test3.pdf','-dpdf')

All three test files end up being wrong. If I choose "Save As" in the figure menu I am able to save the figure correctly.

Any ideas how to resolve the issue? 

Answer: 

To keep the background as in your figure, use the command set. 

set(gcf, 'InvertHardCopy', 'off'); 

 


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com