Stackplot

Memory Allocation

RAM usage by application type.

Output
Memory Allocation
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'system': '#EF4444',
    'apps': '#6366F1',
    'cache': '#10B981',
    'free': '#94A3B8',
    'background': '#FFFFFF',
    'text': '#1E293B',
    'text_muted': '#64748B',
    'grid': '#F1F5F9'
}

time = np.arange(0, 61)
np.random.seed(42)
system = 2 + 0.3*np.sin(time/10) + np.random.normal(0, 0.1, 61)
apps = 3 + 2*np.sin(time/15) + time*0.02 + np.random.normal(0, 0.2, 61)
cache = 1.5 + 0.5*np.sin(time/8) + np.random.normal(0, 0.1, 61)
total_used = system + apps + cache
free = 8 - np.clip(total_used, 0, 7)

fig, ax = plt.subplots(figsize=(12, 5), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])

ax.stackplot(time, system, apps, cache, free,
             colors=[COLORS['system'], COLORS['apps'], COLORS['cache'], COLORS['free']],
             alpha=0.85, labels=['System', 'Applications', 'Cache', 'Free'])

ax.axhline(8, color=COLORS['text'], linewidth=1, linestyle='--', alpha=0.3)
ax.text(62, 8, '8GB', fontsize=9, color=COLORS['text_muted'], va='center')

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.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlim(0, 60)
ax.set_ylim(0, 9)
ax.set_xlabel('Time (min)', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('RAM (GB)', 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

Did this help you?

Support PyLucid to keep it free & growing

Support