[教程] [Matplotlib] 生成背景透明的图片

长话短说

测试环境

  • macOS Catalina 10.15.3
  • Python 3.7.3
  • Matplotlib 3.1.3

方案一

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
fig.patch.set_alpha(0.)  # 或者其他值

方案二

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

# 绘制图片
...

# 保存图片
fig.savefig('xovee.svg', transparent=True)
发布了40 篇原创文章 · 获赞 84 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/xovee/article/details/104651123