2022-06-25

Can I print pie charts using a for loop in Jupyter?

I need to use for loops to print multiple pie charts within a function, preferably horizontally. My assumption was, if I use a for loop to print pie charts, all the charts will be produced but the results would be shown vertically. However, only the very last figure is shown.

import matplotlib.pyplot as plt
for i in range(3):
    labels = ['part_1','part_2','part_3']
    pie_portions = [5,6,7]
    plt.pie(pie_portions,labels=labels,autopct = '%1.1f%%')
    plt.title(f'figure_no : {i+1}')


No comments:

Post a Comment