Linear Regression Plot
Revenue vs Marketing Spend Correlation
Business growth analysis showing marketing ROI
Output
Python
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
np.random.seed(401)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
# Generate correlated data
n = 80
marketing = np.random.uniform(10, 100, n)
revenue = 2.5 * marketing + np.random.normal(0, 20, n) + 50
df = pd.DataFrame({'Marketing Spend ($K)': marketing, 'Revenue ($K)': revenue})
fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)
sns.regplot(
data=df,
x='Marketing Spend ($K)',
y='Revenue ($K)',
scatter_kws={'color': '#27D3F5', 'alpha': 0.7, 's': 60, 'edgecolor': 'white', 'linewidths': 0.5},
line_kws={'color': '#F5276C', 'linewidth': 2.5, 'alpha': 0.9},
ci=95,
ax=ax
)
# Style confidence interval
for collection in ax.collections[1:]:
collection.set_facecolor('#F5276C')
collection.set_alpha(0.15)
corr = np.corrcoef(marketing, revenue)[0, 1]
ax.text(0.05, 0.95, 'r = %.3f' % corr, transform=ax.transAxes, fontsize=12,
color='#F5276C', fontweight='bold', va='top',
bbox=dict(boxstyle='round,pad=0.3', facecolor='#1a1a2e', edgecolor='#333'))
ax.set_xlabel('Marketing Spend ($K)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Revenue ($K)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Revenue vs Marketing Spend', 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
More Linear Regression Plot examples
☕