from matplotlib import pyplot as plt
plt.style.use('fivethirtyeight')
slices = [ 120, 70 ]
labels = ['Android', 'ios']
#plotting pie chart
plt.pie(slices, labels=labels)
plt.title("My Awesome Pie Chart")
plt.tight_layout()
plt.show()
#adding margin
plt.pie(slices, labels=labels, wedgeprops={'edgecolor':'black'})
plt.title("My Awesome Pie Chart")
plt.tight_layout()
plt.show()
slices = [ 120, 70, 30, 20 ]
labels = [ 'icecream', 'chocolate', 'pizza', 'burger' ]
colors = [ '#008fd5', '#fc4f30', '#e5ae37', '#6d904f' ]
#colors hexcode
# blue = #008fd5
# red = #fc4f30
# yellow = #e5ae37
# green = #6d904f
plt.pie(slices, labels=labels, wedgeprops={'edgecolor':'black'}, colors=colors)
plt.title("My Awesome Pie Chart")
plt.tight_layout()
plt.show()
# Language Popularity
slices = [59219, 55466, 47544, 36443, 35917, 31991, 27097, 23030, 20524, 18523, 18017, 7920, 7331, 7201, 5833]
labels = ['JavaScript', 'HTML/CSS', 'SQL', 'Python', 'Java', 'Bash/Shell/PowerShell', 'C#', 'PHP', 'C++', 'TypeScript', 'C', 'Other(s):', 'Ruby', 'Go', 'Assembly']
plt.pie(slices, labels=labels, wedgeprops={'edgecolor':'black'})
plt.title("My Awesome Pie Chart")
plt.tight_layout()
plt.show()
# Emphasis on particular label using explode
slices = [59219, 55466, 47544, 36443, 35917]
labels = ['JavaScript', 'HTML/CSS', 'SQL', 'Python', 'Java']
explode= [ 0, 0, 0, 0.1, 0]
#passing explode to pie chart, setting shadow, starting angle, adding percentage
plt.pie(slices, labels=labels, wedgeprops={'edgecolor':'black'},
explode=explode,shadow=True, startangle=90, autopct='%1.1f%%')
plt.title("My Awesome Pie Chart")
plt.tight_layout()
plt.show()