Save MATLAB figure with different background color

独自空忆成欢 提交于 2019-12-09 05:14:16

问题


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?


回答1:


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

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

For adjusting the figure in other ways, check out this link

http://www.mathworks.com/help/techdoc/creating_plots/f3-84337.html



来源:https://stackoverflow.com/questions/4886195/save-matlab-figure-with-different-background-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!