Linear Regression Plot

Thermal Conductivity Analysis

Materials science temperature dependence with phase transition

Output
Thermal Conductivity Analysis
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(4444)

# Thermal conductivity data
temp = np.linspace(100, 500, 55)
# Typical metal behavior with Umklapp scattering
k = 400 / (1 + 0.002 * temp) + np.random.normal(0, 8, 55)

slope, intercept, r_value, _, _ = stats.linregress(temp, k)
t_fit = np.linspace(100, 500, 100)
k_fit = 400 / (1 + 0.002 * t_fit)

fig, ax = plt.subplots(figsize=(10, 7), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

ax.yaxis.grid(True, color='#f0f0f0', linewidth=1, zorder=1)
ax.xaxis.grid(True, color='#f0f0f0', linewidth=1, zorder=1)

ax.fill_between(t_fit, k_fit - 12, k_fit + 12, color='#4927F5', alpha=0.1, linewidth=0, zorder=2)
ax.plot(t_fit, k_fit, color='#4927F5', linewidth=2.5, zorder=3)
ax.scatter(temp, k, c='#6CF527', s=55, alpha=0.85, edgecolors='white', linewidths=0.6, zorder=4)

# Temperature regime annotation
ax.annotate('phonon-dominated', xy=(150, 350), fontsize=9, color='#666666',
            arrowprops=dict(arrowstyle='->', color='#888888', lw=0.8), xytext=(200, 380))

# Material label
ax.text(0.97, 0.95, 'Cu (99.99%)', transform=ax.transAxes, fontsize=11,
        color='#F5B027', ha='right', va='top', fontweight='bold')

for spine in ['top', 'right']:
    ax.spines[spine].set_visible(False)
for spine in ['bottom', 'left']:
    ax.spines[spine].set_color('#cccccc')

ax.set_xlabel('Temperature (K)', fontsize=12, color='#333333', fontweight='500', labelpad=10)
ax.set_ylabel('Thermal Conductivity (W/m·K)', fontsize=12, color='#333333', fontweight='500', labelpad=10)
ax.set_title('Temperature-Dependent Conductivity', fontsize=15, color='#1a1a1a', fontweight='bold', pad=20, loc='left')
ax.tick_params(colors='#666666', labelsize=10, length=0)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support