Skip to content

Instantly share code, notes, and snippets.

@Thiagobc23
Last active November 3, 2021 01:58
Show Gist options
  • Save Thiagobc23/765362f88e8ea22d8b14c180f5f68c1a to your computer and use it in GitHub Desktop.
Save Thiagobc23/765362f88e8ea22d8b14c180f5f68c1a to your computer and use it in GitHub Desktop.
Donut chart with Matplotlib
import matplotlib.pyplot as plt
data = [87,13]
fig, ax = plt.subplots(figsize=(6, 6))
wedgeprops = {'width':0.3, 'edgecolor':'black', 'linewidth':3}
ax.pie(data, wedgeprops=wedgeprops, startangle=90, colors=['#5DADE2', '#515A5A'])
plt.title('Worldwide Access to Electricity', fontsize=24, loc='left')
plt.text(0, 0, "87%", ha='center', va='center', fontsize=42)
plt.text(-1.2, -1.2, "Source: ourworldindata.org/energy-access", ha='left', va='center', fontsize=12)
plt.tight_layout()
plt.savefig('donut.png')
@Thiagobc23
Copy link
Author

donut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment