Linear Regression Plot

CPU Clock Speed vs Power Consumption

Hardware performance and energy efficiency analysis

Output
CPU Clock Speed vs Power Consumption
Python
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

np.random.seed(402)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'

n = 70
clock_speed = np.random.uniform(2.0, 5.5, n)
power = 15 * clock_speed**1.8 + np.random.normal(0, 15, n)

df = pd.DataFrame({'Clock Speed (GHz)': clock_speed, 'Power (W)': power})

fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)

sns.regplot(
    data=df,
    x='Clock Speed (GHz)',
    y='Power (W)',
    scatter_kws={'color': '#6CF527', 'alpha': 0.7, 's': 55, 'edgecolor': 'white', 'linewidths': 0.5},
    line_kws={'color': '#F5B027', 'linewidth': 2.5, 'linestyle': '-'},
    ci=95,
    ax=ax
)

for collection in ax.collections[1:]:
    collection.set_facecolor('#F5B027')
    collection.set_alpha(0.15)

corr = np.corrcoef(clock_speed, power)[0, 1]
ax.text(0.05, 0.95, 'r = %.3f' % corr, transform=ax.transAxes, fontsize=12,
        color='#F5B027', fontweight='bold', va='top',
        bbox=dict(boxstyle='round,pad=0.3', facecolor='#1a1a2e', edgecolor='#333'))

ax.set_xlabel('Clock Speed (GHz)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Power Consumption (W)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('CPU Performance vs Power', fontsize=14, color=TEXT_COLOR, fontweight='bold', pad=15)

ax.tick_params(colors='#888', labelsize=10)
for spine in ax.spines.values():
    spine.set_color('#333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support