Correlogram
Automotive Engine Correlogram
Automotive correlogram of engine metrics by fuel type
Output
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
np.random.seed(987)
n = 170
fuel = np.random.choice(['Gasoline', 'Diesel', 'Hybrid'], n)
data = {
'MPG': np.where(fuel == 'Hybrid', np.random.normal(50, 8, n),
np.where(fuel == 'Diesel', np.random.normal(35, 5, n), np.random.normal(28, 6, n))),
'HP': np.where(fuel == 'Gasoline', np.random.normal(250, 60, n),
np.where(fuel == 'Diesel', np.random.normal(200, 40, n), np.random.normal(180, 30, n))),
'Torque': np.where(fuel == 'Diesel', np.random.normal(350, 70, n),
np.where(fuel == 'Gasoline', np.random.normal(270, 50, n), np.random.normal(220, 40, n))),
'Weight (lbs)': np.where(fuel == 'Hybrid', np.random.normal(3800, 300, n),
np.where(fuel == 'Diesel', np.random.normal(4200, 400, n), np.random.normal(3500, 350, n))),
'Fuel': fuel
}
df = pd.DataFrame(data)
sns.set_style("whitegrid", {'axes.facecolor': '#ffffff', 'figure.facecolor': '#ffffff', 'grid.color': '#eeeeee'})
palette = {'Gasoline': '#F54927', 'Diesel': '#4927F5', 'Hybrid': '#6CF527'}
g = sns.pairplot(
df,
hue='Fuel',
palette=palette,
height=2,
kind='scatter',
diag_kind='kde',
markers=['o', 's', 'D'],
plot_kws={'alpha': 0.75, 's': 55, 'edgecolor': 'white', 'linewidths': 0.6},
diag_kws={'alpha': 0.5, 'linewidth': 2.5, 'fill': True}
)
g.fig.set_facecolor('#ffffff')
for ax in g.axes.flat:
if ax:
ax.set_facecolor('#ffffff')
for spine in ax.spines.values():
spine.set_color('#dddddd')
ax.tick_params(colors='#666666')
ax.xaxis.label.set_color('#333333')
ax.yaxis.label.set_color('#333333')
g.fig.suptitle('Automotive Performance Metrics', fontsize=14, fontweight='bold', color='#1a1a1a', y=1.02)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
More Correlogram examples
☕