解决python的matplotlib库,将多个图保存为多个文件造成重叠的问题
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
plt.style.use('dark_background')
for i in range(2):
if i ==0:
labels = 'A', 'B', 'C'
fracs = [20, 30, 50]
plt.pie(x=fracs, labels=labels, autopct='%3.1f %%',
shadow=True, labeldistance=1.1, startangle=90, pctdistance=0.6 )
plt.savefig("temp1.png")
plt.clf()#添加上这一行,画完第一个图后,重置一下
if i ==1:
labels = 'Q', 'W', 'E'
fracs = [30, 30, 40]
plt.pie(x=fracs, labels=labels, autopct='%3.1f %%',
shadow=True, labeldistance=1.1, startangle=90, pctdistance=0.6 )
plt.savefig("temp2.png")
————————————————
版权声明:本文为CSDN博主「qqqeeevvv」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/acl_lihan/article/details/90900287