Tuesday, 1 June 2021

How to make a piechart

How to make a piechart




import matplotlib.pyplot as plt


# Pie chart, where the slices will be ordered and plotted counter-clockwise:

labels = outcome.index

sizes = outcome

explode = (0, 0.1)  # only "explode" the 2nd slice (i.e. '1')


fig, (ax1,ax2)=plt.subplots(1,2, figsize=(14,8))

ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',

        shadow=True)

ax2.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',

        shadow=True)

ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.

ax2.axis('equal')

plt.show()


No comments:

Post a Comment