4.7. Pie Chart#

  • Try to keep slices low

    • Group ‘others’ into single slice

import pandas as pd
import matplotlib.pyplot as plt
data = {'Month':['Jan','Feb','March','April'],
        'Sales': [99, 98, 95, 90],
        'Profit': [10,20,30,40]
       }
df=pd.DataFrame(data,columns=['Sales','Profit'],index=data['Month'])
df
Sales Profit
Jan 99 10
Feb 98 20
March 95 30
April 90 40
fig,ax=plt.subplots()
ax.pie(df['Sales']) ;
../_images/d1e9afef7a98bf0e475fa6b455be4d2d0d5214991a5d6cbb33f95a3b2200954e.png

4.7.1. Customizations#

fig,ax=plt.subplots()
ax.pie(df['Sales'],
      labels=df.index,
      autopct='%.0f%%') ;
../_images/266785b8278831863783aae66eba418ac41d6e8c9aa79fe01dfd7d07153ea0ad.png