Gauge Chart

Reactor Temperature Gauge

Industrial temperature monitoring with adaptive fire gradient

Output
Reactor Temperature Gauge
Python
import matplotlib.pyplot as plt
from matplotlib.patches import Wedge, Circle, Polygon
import numpy as np

# Data
temp = 72  # Celsius
min_temp, max_temp = 0, 120
value = ((temp - min_temp) / (max_temp - min_temp)) * 100

# Dynamic color based on temperature
if temp < 40:
    arc_color = '#27D3F5'  # Cool
elif temp < 80:
    arc_color = '#F5B027'  # Warm
else:
    arc_color = '#F54927'  # Hot

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

start_angle, end_angle = -30, 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')

# Temperature zones on track
zones = [(0, 40, '#27D3F5'), (40, 80, '#F5B027'), (80, 120, '#F54927')]
for z_start, z_end, z_color in zones:
    z_s_pct = (z_start - min_temp) / (max_temp - min_temp)
    z_e_pct = (z_end - min_temp) / (max_temp - min_temp)
    z_s_ang = end_angle - z_s_pct * sweep
    z_e_ang = end_angle - z_e_pct * sweep
    ax.add_patch(Wedge((0, 0), 1.0, z_e_ang, z_s_ang, width=0.15,
                       facecolor=z_color, edgecolor='none', alpha=0.15))

# Value arc
value_pct = value / 100
value_angle = start_angle + (1 - value_pct) * sweep
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)]:
    ax.add_patch(Wedge((0, 0), 1.0 + r_off, value_angle, end_angle,
                       width=0.15 + w_off, facecolor=arc_color, edgecolor='none', alpha=alpha))

# Ticks with temperature labels
for i in range(5):
    pct = i / 4
    angle = np.radians(end_angle - pct * sweep)
    temp_val = min_temp + pct * (max_temp - min_temp)
    ax.plot([0.87*np.cos(angle), 0.80*np.cos(angle)], 
            [0.87*np.sin(angle), 0.80*np.sin(angle)], color='#3a3a4a', linewidth=2)
    ax.text(0.72*np.cos(angle), 0.72*np.sin(angle), f'{int(temp_val)}°',
            fontsize=10, color=dim_color, ha='center', va='center')

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

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

# 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.22, f'{temp}°C', fontsize=52, fontweight='bold', color=text_color, ha='center', va='center')
status = 'COLD' if temp < 40 else 'OPTIMAL' if temp < 80 else 'HOT'
ax.text(0, -0.42, status, fontsize=16, color=arc_color, ha='center', va='center', fontweight='bold')
ax.text(0, 1.22, 'Reactor Temperature', 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