Scatter Plot
Bubble Scatter Plot
Modern scatter plot with size encoding
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# === STYLE CONFIG ===
COLORS = {
'bubbles': '#6366F1',
'background': '#FAFBFC',
'text': '#1E293B',
'text_muted': '#64748B',
'grid': '#E2E8F0',
}
# === DATA ===
np.random.seed(42)
n = 30
x = np.random.uniform(1, 9, n)
y = np.random.uniform(1, 9, n)
sizes = np.random.uniform(100, 1000, n)
colors = np.random.uniform(0.3, 1, n)
# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
# === PLOT ===
scatter = ax.scatter(x, y, s=sizes, c=colors, cmap='viridis', alpha=0.6,
edgecolors='white', linewidths=1.5)
# === AXES ===
ax.set_xlim(0, 10)
ax.set_ylim(0, 10)
ax.set_xlabel('X Axis', fontsize=10, color=COLORS['text_muted'], labelpad=10)
ax.set_ylabel('Y Axis', fontsize=10, color=COLORS['text_muted'], labelpad=10)
# === 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.xaxis.grid(True, color=COLORS['grid'], linewidth=0.5)
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=0.5)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Pairwise Data
More Scatter Plot examples
☕