Scatter Plot
Logarithmic Regression
Log curve showing diminishing returns pattern.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'points': '#10B981',
'trend': '#10B981',
'background': '#FFFFFF',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#F1F5F9',
}
# === DATA ===
np.random.seed(42)
x = np.linspace(1, 100, 50)
y = 15 * np.log(x) + 5 + np.random.normal(0, 3, 50)
# Log fit
log_x = np.log(x)
z = np.polyfit(log_x, y, 1)
x_smooth = np.linspace(1, 100, 200)
y_fit = z[0] * np.log(x_smooth) + z[1]
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
# Trend with glow
ax.plot(x_smooth, y_fit, color=COLORS['trend'], linewidth=8, alpha=0.15, zorder=1)
ax.plot(x_smooth, y_fit, color=COLORS['trend'], linewidth=2.5,
label='Logarithmic fit', zorder=2)
# Points with glow
ax.scatter(x, y, s=150, c=COLORS['points'], alpha=0.15, zorder=3)
ax.scatter(x, y, s=60, c=COLORS['points'], alpha=0.8,
edgecolors='white', linewidths=1.5, zorder=4)
# Annotation
ax.annotate('Diminishing returns', xy=(70, y_fit[140]),
xytext=(50, 75),
fontsize=9, color=COLORS['text_muted'],
arrowprops=dict(arrowstyle='->', color=COLORS['text_muted'], lw=1.5))
# === STYLING ===
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=1)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_xlabel('Investment ($K)', fontsize=10, color=COLORS['text'], labelpad=10)
ax.set_ylabel('Return (%)', fontsize=10, color=COLORS['text'], labelpad=10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12),
frameon=False, fontsize=9, labelcolor=COLORS['text_muted'])
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Pairwise Data
More Scatter Plot examples
☕