How to export plots from matplotlib with transparent background?

前端 未结 2 1101
一生所求
一生所求 2020-12-07 13:49

I am using matplotlib to make some graphs and unfortunately I cannot export them without the white background.

<script

2条回答
  •  失恋的感觉
    2020-12-07 14:16

    Png files can handle transparency. So you could use this question Save plot to image file instead of displaying it using Matplotlib so as to save you graph as a png file.

    And if you want to turn all white pixel transparent, there's this other question : Using PIL to make all white pixels transparent?

    If you want to turn an entire area to transparent, then there's this question: And then use the PIL library like in this question Python PIL: how to make area transparent in PNG? so as to make your graph transparent.

提交回复
热议问题