Pie Chart

Time Spent Analysis

Daily activity breakdown donut chart

Output
Time Spent Analysis
Python
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(figsize=(10, 8), facecolor='#18181b')
ax.set_facecolor('#18181b')

sizes = [8, 8, 2, 1.5, 2.5, 2]
labels = ['Sleep', 'Work', 'Exercise', 'Commute', 'Leisure', 'Meals']
colors = ['#6366f1', '#f43f5e', '#22c55e', '#f97316', '#a855f7', '#eab308']

wedges, texts, autotexts = ax.pie(sizes, labels=None, colors=colors,
                                   autopct=lambda p: f'{p*24/100:.1f}h',
                                   startangle=90,
                                   wedgeprops={'linewidth': 3, 'edgecolor': '#18181b', 'width': 0.55},
                                   pctdistance=0.75)

for autotext in autotexts:
    autotext.set_color('#ffffff')
    autotext.set_fontsize(10)
    autotext.set_fontweight('bold')

centre_circle = plt.Circle((0, 0), 0.45, fc='#18181b')
ax.add_patch(centre_circle)
ax.text(0, 0, '24h', ha='center', va='center', color='#71717a', fontsize=20, fontweight='bold')

ax.legend(wedges, labels, loc='center left', bbox_to_anchor=(1, 0.5),
          facecolor='#18181b', edgecolor='#3f3f46', labelcolor='#a1a1aa', fontsize=10)

plt.tight_layout()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support