Setting axis background color and saving as pdf

10 次查看(过去 30 天)
Hi,
I'm trying to saveas a pdf of a figure in which the axis background is light gray, while the rest of the background (figure background, I suppose?) is the standard clear/white. I've tried this by setting the background to gray by:
set(gca,'Color',[.8 .8 .8]);
but saveas seems to cancel this color change out. I've also tried using:
set(gcf,'InvertHardCopy','off');
and this sets the entire figure background to gray (as seen in the attached image), but I don't want the area outside the plot to be gray. Can anyone help with this?
Thanks, Jonathan

回答(1 个)

Jonathan
Jonathan 2014-1-17
I figured out a bit of a workaround for this problem which is suitable for my purposes, but may not be for others... If you set the whole background to white and then the axis background to gray and set the gcf "InvertHardCopy" to 'off', then the figure comes out looking more or less right for any situation that requires/allows a white background. This would be:
set(gcf,'Color',[1 1 1]); set(gca,'Color',[.8 .8 .8]); set(gcf,'InvertHardCopy','off');
Attached plot shows this (with some other corrections to the data that are unrelated).
I guess I answered my question well enough for this time, but I'd still like to know whether this can be done in a way that preserves the background as the original "clear" in case I'm interested in pasting my pdf file into non-white-backgrounded documents in the future.

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by