Faceted Scatter Plot
Learning Rate by Teaching Method
Educational outcomes faceted by instructional approach
Output
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
np.random.seed(111)
methods = ['Lecture', 'Interactive', 'Project-Based', 'Hybrid']
data = []
for method in methods:
n = 40
study_hours = np.random.uniform(1, 20, n)
effectiveness = {'Lecture': 3.5, 'Interactive': 4.5, 'Project-Based': 5.0, 'Hybrid': 4.8}
score = effectiveness[method] * np.sqrt(study_hours) + 40 + np.random.normal(0, 5, n)
score = np.clip(score, 0, 100)
for s, sc in zip(study_hours, score):
data.append({'Study Hours': s, 'Test Score': sc, 'Method': method})
df = pd.DataFrame(data)
plt.style.use('dark_background')
sns.set_style("darkgrid", {
'axes.facecolor': '#0a0a0f',
'figure.facecolor': '#0a0a0f',
'grid.color': '#333333'
})
palette = ['#C82909', '#4927F5', '#27F5B0', '#F5D327']
g = sns.lmplot(
data=df,
x='Study Hours',
y='Test Score',
hue='Method',
col='Method',
col_wrap=2,
height=3.5,
aspect=1.2,
palette=palette,
scatter_kws={'alpha': 0.75, 's': 50, 'edgecolor': 'white', 'linewidths': 0.4},
line_kws={'linewidth': 2.5},
ci=95
)
g.fig.set_facecolor('#0a0a0f')
for ax in g.axes.flat:
ax.set_facecolor('#0a0a0f')
for spine in ax.spines.values():
spine.set_color('#333333')
g.fig.suptitle('Pedagogical Effectiveness', fontsize=14, fontweight='bold', color='white', y=1.02)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Pairwise Data
More Faceted Scatter Plot examples
☕