Donut Chart
Chart overview
Donut charts are pie charts with a hollow center, which can display summary statistics or labels.
Key points
- The ring format emphasizes the proportions between segments while providing space for central annotations like totals or key metrics.
Python Tutorial
How to create a donut chart in Python
Use the full tutorial for implementation details, troubleshooting, and chart variations in matplotlib, seaborn, and plotly.
How to Create a Bar Chart in PythonExample Visualization

Create This Chart Now
Generate publication-ready donut charts with AI in seconds. No coding required – just describe your data and let AI do the work.
View example prompt
"Create an interactive donut chart showing 'Global Browser Market Share' for 2024. Generate realistic data: Chrome (65.4%), Safari (18.2%), Edge (5.1%), Firefox (3.0%), Samsung Internet (2.5%), Opera (2.3%), Other (3.5%). Use distinct brand colors: Chrome (green/red/yellow), Safari (blue), Edge (blue-green), Firefox (orange), others (grays). Display percentage labels on each segment (only for segments >3%). Add a center annotation showing 'Total: 4.8B Users' and the leading browser's logo/name. Include hover tooltips with exact user counts. Slight separation (explode) for the largest segment. Add a legend on the right. Title: 'Browser Market Share - Q1 2024'. Animate on load with a spin-in effect."
How to create this chart in 30 seconds
Upload Data
Drag & drop your Excel or CSV file. Plotivy securely processes it in your browser.
AI Generation
Our AI analyzes your data and generates the Donut Chart code automatically.
Customize & Export
Tweak the design with natural language, then export as high-res PNG, SVG or PDF.
Newsletter
Get one weekly tip for better donut charts
Join researchers receiving concise Python plotting techniques to improve chart clarity and reduce revision cycles.
Python Code Example
# === IMPORTS ===
import pandas as pd
import numpy as np
import plotly.express as px
# === USER-EDITABLE PARAMETERS ===
title = "Global Browser Market Share - Q1 2024 (4.8B Users Total)"
figsize_width = 800
figsize_height = 600
# === EXAMPLE DATASET ===
data = {
'Browser': ['Chrome', 'Safari', 'Edge', 'Firefox', 'Samsung Internet', 'Opera', 'Other'],
'Market_Share': [65.4, 18.2, 5.1, 3.0, 2.5, 2.3, 3.5],
'Users_M': [3139, 874, 245, 144, 120, 110, 168] # Users in millions
}
# Brand colors
colors = {
'Chrome': '#4285F4',
'Safari': '#0066CC',
'Edge': '#0078D7',
'Firefox': '#FF7139',
'Samsung Internet': '#1428A0',
'Opera': '#FF1B2D',
'Other': '#808080'
}
df = pd.DataFrame(data)
df['Color'] = df['Browser'].map(colors)
# Print summary
print("=== Browser Market Share Summary ===")
print(f"\nTotal Users: {df['Users_M'].sum():,}M")
print(f"\nMarket Share by Browser:")
for _, row in df.iterrows():
print(f" {row['Browser']}: {row['Market_Share']:.1f}% ({row['Users_M']:,}M users)")
# === CREATE DONUT CHART ===
fig = px.pie(
df,
values='Market_Share',
names='Browser',
title=title,
hole=0.5,
color='Browser',
color_discrete_map=colors
)
fig.update_traces(
textposition='outside',
textinfo='label+percent',
hovertemplate='<b>%{label}</b><br>%{value:.1f}%<br>~%{customdata[0]:,}M users<extra></extra>',
customdata=df[['Users_M']].values
)
fig.update_layout(
width=figsize_width,
height=figsize_height,
annotations=[
dict(text='4.8B<br>Users', x=0.5, y=0.5, font_size=18, showarrow=False)
],
showlegend=True,
legend=dict(orientation='v', yanchor='middle', y=0.5, xanchor='left', x=1.02)
)
fig.show()
# END-OF-CODE
Opens the Analyze page with this code pre-loaded and ready to execute
Console Output
Leading Browser: Chrome (65.4%) Total Users: 4.8 billion Top 3 Combined: 88.7%
Common Use Cases
- 1Market share display
- 2Budget allocation
- 3Survey responses
- 4Portfolio composition
Pro Tips
Limit to 5-7 segments
Use center for key metric
Sort segments by size
Long-tail keyword opportunities
High-intent chart variations
Library comparison for this chart
matplotlib
Best when you need full control over axis formatting, annotation placement, and journal-specific styling for donut-chart.
plotly
Best for interactive hover, zoom, and web sharing when collaborators need to inspect values directly from donut-chart figures.
Scientific Chart Selection Cheat Sheet
Not sure whether to use a Violin Plot, Box Plot, or Ridge Plot? Download our single-page reference mapping the most-used scientific chart types, exactly when to use them, and the core Matplotlib/Seaborn functions.