#!/usr/bin/env python # coding: utf-8 # In[1]: from matplotlib import pyplot as plt # In[2]: plt.style.use('seaborn-white') plt.rc('figure', figsize=(8, 6)) # In[3]: # slices = [60, 40] # Colors: # Blue = #008fd5 # Red = #fc4f30 # Yellow = #e5ae37 # Green = #6d904f slices = [120, 80, 30, 20] labels = ['Sixty', 'forty', 'Extra1', 'Extra1'] colors = ['#008fd5', '#fc4f30', '#e5ae37', '#6d904f'] # https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.patches.Wedge.html plt.pie(slices, labels=labels, colors=colors, wedgeprops={'edgecolor': 'black'}) plt.title('My Awesome Pie Chart') plt.tight_layout() plt.show() # In[4]: # Language Popularity slices = [59219, 55466, 47544, 36443, 35917] labels = ['JavaScript', 'HTML/CSS', 'SQL', 'Python', 'Java'] # In[5]: explode = [0, 0, 0, 0.1, 0] # In[6]: plt.xkcd() plt.pie(slices, labels=labels, explode=explode, shadow=True, startangle=90, autopct='%1.1f%%', wedgeprops={'edgecolor': 'black'}) # explode - to emphasis on a cut # shadow - to give a shadow to the chart # startangle - start at a certain angle # autopct - calculate percentages plt.title('My Awesome Pie Chart') plt.tight_layout() plt.savefig(r'plots/plot3-1.png') plt.show()