Stackplot
App Usage Hours
Daily screen time by application.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {
'social': '#EC4899',
'productivity': '#10B981',
'entertainment': '#F59E0B',
'other': '#6366F1',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9'
}
days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
x = np.arange(len(days))
social = [2.5, 2.8, 2.2, 2.6, 3.0, 4.5, 5.0]
productivity = [4.0, 3.5, 4.2, 3.8, 3.0, 1.5, 1.0]
entertainment = [1.5, 1.8, 2.0, 2.2, 3.5, 4.0, 4.5]
other = [1.0, 1.2, 1.0, 1.1, 1.5, 2.0, 1.8]
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
ax.stackplot(x, social, productivity, entertainment, other,
colors=[COLORS['social'], COLORS['productivity'], COLORS['entertainment'], COLORS['other']],
alpha=0.85, labels=['Social', 'Productivity', 'Entertainment', 'Other'])
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=1, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xticks(x)
ax.set_xticklabels(days)
ax.set_ylabel('Hours', fontsize=10, color=COLORS['text'], labelpad=10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), ncol=4, frameon=False, fontsize=9, labelcolor=COLORS['text_muted'])
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Stackplot examples
☕