Effacer les filtres
Effacer les filtres

Setting axis background color and saving as pdf

10 vues (au cours des 30 derniers jours)
Jonathan
Jonathan le 17 Jan 2014
Commenté : Mark Vaughan le 29 Sep 2020
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

Réponses (1)

Jonathan
Jonathan le 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.
  1 commentaire
Mark Vaughan
Mark Vaughan le 29 Sep 2020
this solution works wonderfully well...thanks!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by