Tuesday, 17 February 2026

๐Ÿฉ Day 26: Donut Chart in Python

 

๐Ÿฉ Day 26: Donut Chart in Python

๐Ÿ”น What is a Donut Chart?

A Donut Chart is a variation of a pie chart with a hole in the center.
It shows part-to-whole relationships, just like a pie chart, but with better readability.


๐Ÿ”น When Should You Use It?

Use a donut chart when:

  • You want a cleaner, modern look

  • Showing percentage distribution

  • You want space in the center for labels or totals


๐Ÿ”น Example Scenario

  • Website traffic sources

  • Budget allocation

  • Product-wise revenue contribution

The donut chart highlights dominant categories clearly.


๐Ÿ”น Key Idea Behind It

๐Ÿ‘‰ Circular chart representing 100%
๐Ÿ‘‰ Inner hole reduces clutter
๐Ÿ‘‰ Center can display total or key insight


๐Ÿ”น Python Code (Donut Chart)

import matplotlib.pyplot as plt
labels = ['Product A', 'Product B', 'Product C', 'Product D']
sizes = [45, 25, 20, 10]
fig, ax = plt.subplots() ax.pie( sizes,
labels=labels,
autopct='%1.1f%%',
startangle=90,
wedgeprops=dict(width=0.4)
)
ax.set_title('Revenue Distribution')
plt.show()

๐Ÿ”น Output Explanation

  • Each slice shows percentage contribution

  • The center hole improves clarity

  • Width controls donut thickness


๐Ÿ”น Donut Chart vs Pie Chart

AspectDonut ChartPie Chart
ReadabilityBetterAverage
Visual appealHighBasic
Center textPossible
Use caseDashboardsSimple visuals

0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (118) AI (202) Android (25) AngularJS (1) Api (7) Assembly Language (2) aws (28) Azure (8) BI (10) Books (262) Bootcamp (1) C (78) C# (12) C++ (83) Course (84) Coursera (299) Cybersecurity (29) data (1) Data Analysis (26) Data Analytics (18) data management (15) Data Science (287) Data Strucures (15) Deep Learning (119) Django (16) Downloads (3) edx (21) Engineering (15) Euron (30) Events (7) Excel (18) Finance (9) flask (3) flutter (1) FPL (17) Generative AI (59) Git (9) Google (47) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (41) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (242) Meta (24) MICHIGAN (5) microsoft (9) Nvidia (8) Pandas (13) PHP (20) Projects (32) Python (1256) Python Coding Challenge (1032) Python Mistakes (50) Python Quiz (422) Python Tips (5) Questions (3) R (72) React (7) Scripting (3) security (4) Selenium Webdriver (4) Software (19) SQL (46) Udemy (17) UX Research (1) web application (11) Web development (8) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)