I am having one big list which has six small list's. These six small lists are used as the slice values while generating a pie chart using matplotlib.
f_c = [[4, 1, 0, 1, 0],
[4, 1, 0, 1, 0],
[4, 1, 0, 1, 0],
[4, 0, 2, 0, 0],
[4, 0, 2, 0, 0],
[4, 1, 0, 0, 1]]
I have another one list which has the labels
titles = ['Strongly Agree', 'Agree', 'Neutral',
'Disagree', 'Strongly Disagree']
Now, I am using a for loop to save the generated pie-charts. The code is as follows:
for i, j in zip(f_c, lst):
pie(i,
labels=titles,
shadow=True)
savefig(j + '.png')
'lst' is a list that is having file names, and is used to save the the pie charts.
I am able to generate the pie charts, but the charts and labels are getting overwritten. Only the first figure is coming correctly, rest of the figures are getting overwritten. When I did it manually all the figures were generating correctly, but if I put it in a loop it is not getting saved correctly (it's getting overwritten). The following are the generated images (only 3):
,
,
What might be the problem? Kindly help me with this. I am new to matplotlib.