Gauge Chart

CPU Utilization Monitor

Real-time CPU usage with cyan neon glow and needle indicator

Output
CPU Utilization Monitor
Python
import matplotlib.pyplot as plt
from matplotlib.patches import Wedge, Circle, Polygon
import numpy as np

# Data
value = 73
max_value = 100

# Colors
bg_color = '#0a0a0f'
track_color = '#1a1a2e'
arc_color = '#27D3F5'
text_color = '#ffffff'
dim_color = '#6b7280'

# Arc config: 240° sweep from bottom-left to bottom-right
start_angle = -30
end_angle = 210
sweep = end_angle - start_angle

fig, ax = plt.subplots(figsize=(10, 8), facecolor=bg_color)
ax.set_facecolor(bg_color)
ax.set_xlim(-1.4, 1.4)
ax.set_ylim(-0.5, 1.4)
ax.set_aspect('equal')
ax.axis('off')

# Background track
track = Wedge((0, 0), 1.0, start_angle, end_angle, width=0.15,
              facecolor=track_color, edgecolor='none')
ax.add_patch(track)

# Value angle (0% = end_angle, 100% = start_angle)
value_pct = value / max_value
value_angle = start_angle + (1 - value_pct) * sweep

# Value arc with glow
for r_off, w_off, alpha in [(0.05, 0.06, 0.1), (0.03, 0.04, 0.2), 
                             (0.015, 0.02, 0.4), (0, 0, 0.95)]:
    arc = Wedge((0, 0), 1.0 + r_off, value_angle, end_angle, 
                width=0.15 + w_off, facecolor=arc_color, edgecolor='none', alpha=alpha)
    ax.add_patch(arc)

# Tick marks
for i in range(11):
    pct = i / 10
    angle = np.radians(end_angle - pct * sweep)
    r1, r2 = (0.87, 0.80) if i % 5 == 0 else (0.87, 0.83)
    lw = 2 if i % 5 == 0 else 1
    ax.plot([r1*np.cos(angle), r2*np.cos(angle)], 
            [r1*np.sin(angle), r2*np.sin(angle)], 
            color='#3a3a4a', linewidth=lw)
    if i % 5 == 0:
        ax.text(0.72*np.cos(angle), 0.72*np.sin(angle), f'{int(pct*100)}',
                fontsize=11, color=dim_color, ha='center', va='center')

# Needle
needle_angle = np.radians(end_angle - value_pct * sweep)
needle_len = 0.62
nx, ny = needle_len * np.cos(needle_angle), needle_len * np.sin(needle_angle)
perp = needle_angle + np.pi/2
bw = 0.035
bx1, by1 = bw * np.cos(perp), bw * np.sin(perp)
bx2, by2 = -bx1, -by1

# Needle glow
for scale, alpha in [(1.6, 0.1), (1.3, 0.2)]:
    glow = Polygon([(nx*scale, ny*scale), (bx1*2, by1*2), (bx2*2, by2*2)],
                   facecolor=arc_color, edgecolor='none', alpha=alpha)
    ax.add_patch(glow)

# Main needle
needle = Polygon([(nx, ny), (bx1, by1), (bx2, by2)],
                 facecolor='#ffffff', edgecolor='none')
ax.add_patch(needle)

# Center hub
for r, c, a in [(0.11, arc_color, 0.3), (0.09, arc_color, 0.5), 
                (0.07, bg_color, 1), (0.05, arc_color, 0.9)]:
    ax.add_patch(Circle((0, 0), r, facecolor=c, edgecolor='none', alpha=a))

# Text
ax.text(0, -0.25, f'{value}%', fontsize=52, fontweight='bold', 
        color=text_color, ha='center', va='center')
ax.text(0, -0.42, 'CPU USAGE', fontsize=13, color=dim_color, 
        ha='center', va='center', fontweight='500')
ax.text(0, 1.22, 'System Performance', fontsize=18, fontweight='bold',
        color=text_color, ha='center', va='center')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Part-to-Whole

Did this help you?

Support PyLucid to keep it free & growing

Support