5
votes

I'm trying to save a plot with the labels area (the area where you print the xlabel, ylabel and title) transparent and the main plot (the area where you plot the data) not transparent.

enter image description here

I'm using the transparent command in savefig:

plt.savefig("name",tranparent=True)

The problem is that this makes all the figure transparent.

In the documentation says this about the transparent argument:

transparent : bool

If True, the axes patches will all be transparent; the figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs. This is useful, for example, for displaying a plot on top of a colored background on a web page. The transparency of these patches will be restored to their original values upon exit of this function.

So I tried changing the facecolor and edgecolor arguments, but I can't find a combination that gives the plot that I want.

Help.

1

1 Answers

2
votes

There is a bug in the newest version of matplotlib. I'm not sure if this applies to here, because you do not state which version you are using.

The workaround would be to use a transparent facecolor and leave the other arguments at their defaults.

fig.savefig("fname", facecolor=(1,1,1,0))