Setting axis background color and saving as pdf

12 views (last 30 days)
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

Answers (1)

Jonathan
Jonathan on 17 Jan 2014
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.

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!