Setting axis background color and saving as pdf

10 ビュー (過去 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 Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by