Faceted Scatter Plot
Battery Degradation by Chemistry
Cycle life analysis across lithium-ion cell types
Output
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
np.random.seed(987)
chemistries = ['LFP', 'NMC', 'NCA', 'LCO']
data = []
for chem in chemistries:
n = 42
cycles = np.random.uniform(100, 2000, n)
decay_rates = {'LFP': -0.008, 'NMC': -0.012, 'NCA': -0.015, 'LCO': -0.018}
capacity = 100 + decay_rates[chem] * cycles + np.random.normal(0, 2, n)
for cy, cap in zip(cycles, capacity):
data.append({'Charge Cycles': cy, 'Capacity (%)': cap, 'Chemistry': chem})
df = pd.DataFrame(data)
plt.style.use('dark_background')
sns.set_style("darkgrid", {
'axes.facecolor': '#0a0a0f',
'figure.facecolor': '#0a0a0f',
'grid.color': '#333333'
})
palette = ['#6CF527', '#27D3F5', '#F5B027', '#F5276C']
g = sns.lmplot(
data=df,
x='Charge Cycles',
y='Capacity (%)',
hue='Chemistry',
col='Chemistry',
col_wrap=2,
height=3.5,
aspect=1.2,
palette=palette,
scatter_kws={'alpha': 0.7, 's': 48, '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('Battery Longevity Analysis', fontsize=14, fontweight='bold', color='white', y=1.02)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Pairwise Data
More Faceted Scatter Plot examples
☕