Sunburst Chart
REST API Endpoint Hierarchy
Dark-themed sunburst chart showing REST API structure from API version to resource groups to individual endpoints.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(figsize=(12, 10), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
# Inner ring - Resource groups
resource_sizes = [30, 25, 20, 15, 10]
resource_labels = ['/users', '/products', '/orders', '/analytics', '/admin']
resource_colors = ['#27D3F5', '#F5276C', '#6CF527', '#F5B027', '#5314E6']
# Outer ring - Endpoints
endpoint_sizes = [10, 10, 10, 10, 8, 7, 8, 7, 5, 8, 7, 5, 5]
endpoint_colors = ['#27D3F5', '#4DE8FF', '#73EDFF',
'#F5276C', '#FF5A94', '#FF8CB8',
'#6CF527', '#8FFF5C', '#B2FF8C',
'#F5B027', '#FFCC5C',
'#5314E6', '#7B4DFF']
wedges_outer, _ = ax.pie(endpoint_sizes, radius=1, colors=endpoint_colors,
wedgeprops=dict(width=0.3, edgecolor='#0a0a0f', linewidth=2))
wedges_inner, _ = ax.pie(resource_sizes, radius=0.7, colors=resource_colors,
wedgeprops=dict(width=0.3, edgecolor='#0a0a0f', linewidth=2))
# Add resource labels
for i, (wedge, label) in enumerate(zip(wedges_inner, resource_labels)):
ang = (wedge.theta2 - wedge.theta1) / 2 + wedge.theta1
x = 0.55 * np.cos(np.radians(ang))
y = 0.55 * np.sin(np.radians(ang))
ax.text(x, y, label, ha='center', va='center', fontsize=9,
color='white', fontweight='bold')
centre_circle = plt.Circle((0, 0), 0.4, fc='#0a0a0f', ec='#334155', linewidth=2)
ax.add_artist(centre_circle)
ax.text(0, 0, '/api/v2\n45 endpoints', ha='center', va='center',
fontsize=11, color='white', fontweight='bold')
# Legend
endpoint_labels = ['GET list', 'GET :id', 'POST auth', 'GET list', 'GET :id',
'GET search', 'GET list', 'GET :id', 'PATCH status',
'POST events', 'GET metrics', 'GET users', 'PUT settings']
ax.legend(wedges_outer, endpoint_labels, loc='center left', bbox_to_anchor=(1.05, 0.5),
fontsize=9, frameon=True, facecolor='#1e293b', edgecolor='#334155',
labelcolor='white', title='Endpoints', title_fontsize=10)
ax.set_title('API Structure', fontsize=18, color='#f8fafc',
fontweight='bold', pad=20)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Part-to-Whole
More Sunburst Chart examples
☕