Setting axis background color and saving as pdf

조회 수: 14 (최근 30일)
Jonathan
Jonathan 2014년 1월 17일
댓글: Mark Vaughan 2020년 9월 29일
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.
  댓글 수: 1
Mark Vaughan
Mark Vaughan 2020년 9월 29일
this solution works wonderfully well...thanks!!

댓글을 달려면 로그인하십시오.

카테고리

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