How to create a donut chart on Python in 3 screenshots

  • Donut charts are one of the most common types of data visualizations.
  • Each slice represents one component and all slices added together equal the whole.

Screenshot 1 — That your data:

import pandas as pd
import matplotlib.pyplot as plt

Screenshot 2 — That your actions:

plt.pie(df['Sales'], labels=df.index)
my_circle=plt.Circle( (0,0), 0.7, color='white')
p=plt.gcf()
p.gca().add_artist(my_circle)
plt.show()

Screenshot 2 — Let’s make it look better:

fig = plt.figure(figsize=(12, 8))
plt.title("Sales", size=20, fontweight='bold')
plt.pie(df['Sales'], # x values
labels=df.index,
colors=['#AC3E31','#DBAE58','#484848'],
textprops={'fontsize': 14} #font size for labels)
circle=plt.Circle( (0,0), 0.6, color='white')
p=plt.gcf()
p.gca().add_artist(circle)
plt.show()

For more visualization and analytics
https://drivenn.io/