The Python Oracle

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

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 How To Save The Plot With The Labels And Ticks Area Transparent But Not The Main Plot Area In Matplo
01:02 Accepted Answer Score 4
01:21 Thank you

--

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

--

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