The Python Oracle

How to save the plot with the labels and ticks area transparent but not the main plot area in matplotlib?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops

--

Chapters
00:00 Question
01:34 Accepted answer (Score 4)
01:59 Thank you

--

Full question
https://stackoverflow.com/questions/4968...

Question links:
[image]: https://i.stack.imgur.com/3w95Z.png

Accepted answer links:
[bug]: https://github.com/matplotlib/matplotlib...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #matplotlib

#avk47



ACCEPTED ANSWER

Score 4


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))