Linear Regression Plot

Publication Impact Analysis

Citation metrics regression with statistical annotations on clean white background

Output
Publication Impact Analysis
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(444)

# Academic data
impact_factor = np.random.uniform(1, 15, 65)
citations = 3 + 7 * impact_factor + np.random.exponential(8, 65)

slope, intercept, r_value, p_value, std_err = stats.linregress(impact_factor, citations)
x_fit = np.linspace(0, 16, 100)
y_fit = slope * x_fit + intercept

# Prediction interval
n = len(impact_factor)
se = np.sqrt(np.sum((citations - (slope * impact_factor + intercept))**2) / (n - 2))
ci = 1.96 * se

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

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

ax.fill_between(x_fit, y_fit - ci, y_fit + ci, color='#4927F5', alpha=0.1, linewidth=0, zorder=2)
ax.plot(x_fit, y_fit, color='#4927F5', linewidth=2.5, zorder=3)
ax.scatter(impact_factor, citations, c='#F5276C', s=65, alpha=0.8, edgecolors='white', linewidths=0.8, zorder=4)

# Stats box
stats_text = f'β = {slope:.2f} ± {std_err:.2f}\nR² = {r_value**2:.3f}\np < 0.001'
ax.text(0.97, 0.05, stats_text, transform=ax.transAxes, fontsize=10,
        color='#555555', ha='right', va='bottom', family='monospace',
        bbox=dict(boxstyle='round,pad=0.5', facecolor='white', edgecolor='#dddddd'))

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

ax.set_xlabel('Journal Impact Factor', fontsize=12, color='#333333', fontweight='500', labelpad=10)
ax.set_ylabel('Mean Citations per Paper', fontsize=12, color='#333333', fontweight='500', labelpad=10)
ax.set_title('Academic Impact Metrics', 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