I am using matplotlib to make some graphs and unfortunately I cannot export them without the white background.
In other words, when I export a plot like this and position it on top of another image, the white background hides what is behind it rather than allowing it to show through. How can I export plots with a transparent background instead?
Best Answer
Use the matplotlib
savefig
function with the keyword argumenttransparent=True
to save the image as a png file.Result:
Of course, that plot doesn't demonstrate the transparency. Here's a screenshot of the PNG file displayed using the ImageMagick
display
command. The checkerboard pattern is the background that is visible through the transparent parts of the PNG file.