Pie Chart

Sleep Quality Factors

Dark theme donut showing factors affecting sleep quality

Output
Sleep Quality Factors
Python
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

factors = ['Screen Time', 'Stress', 'Caffeine', 'Exercise', 'Diet', 'Environment']
impact = [28, 25, 18, 12, 10, 7]
colors = ['#7c3aed', '#8b5cf6', '#a78bfa', '#c4b5fd', '#ddd6fe', '#ede9fe']

wedges, texts, autotexts = ax.pie(impact, labels=factors, autopct='%1.0f%%',
                                   colors=colors, startangle=90,
                                   wedgeprops={'width': 0.5, 'edgecolor': '#0a0a0f', 'linewidth': 2})

for text in texts:
    text.set_color('white')
    text.set_fontsize(10)
for autotext in autotexts:
    autotext.set_color('white')
    autotext.set_fontweight('bold')

centre_circle = plt.Circle((0, 0), 0.4, fc='#0a0a0f')
ax.add_patch(centre_circle)
ax.text(0, 0, 'Sleep', ha='center', va='center', fontsize=14, fontweight='bold', color='white')

ax.set_title('Sleep Quality Factors', fontsize=16, fontweight='bold', color='white', pad=20)
plt.tight_layout()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support