Last active
November 3, 2021 01:58
-
-
Save Thiagobc23/765362f88e8ea22d8b14c180f5f68c1a to your computer and use it in GitHub Desktop.
Donut chart with Matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
Author
Thiagobc23
commented
Nov 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment