Area Chart
Neural Network Training
Loss curves during deep learning model training
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
epochs = np.arange(1, 101)
# Training and validation loss
train_loss = 2.5 * np.exp(-epochs/20) + 0.1 + np.random.normal(0, 0.02, len(epochs))
val_loss = 2.5 * np.exp(-epochs/25) + 0.15 + np.random.normal(0, 0.03, len(epochs))
# Overfitting after epoch 70
val_loss[70:] = val_loss[70:] + np.linspace(0, 0.3, 30)
fig, ax = plt.subplots(figsize=(10, 6), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
ax.fill_between(epochs, 0, train_loss, alpha=0.3, color='#27D3F5')
ax.fill_between(epochs, 0, val_loss, alpha=0.3, color='#F5276C')
ax.plot(epochs, train_loss, color='#27D3F5', linewidth=2, label='Training Loss')
ax.plot(epochs, val_loss, color='#F5276C', linewidth=2, label='Validation Loss')
# Best epoch marker
best_epoch = np.argmin(val_loss) + 1
ax.axvline(best_epoch, color='#6CF527', linewidth=1.5, linestyle='--', alpha=0.7)
ax.scatter([best_epoch], [val_loss[best_epoch-1]], color='#6CF527', s=100, zorder=5, edgecolors='white')
ax.text(best_epoch + 2, val_loss[best_epoch-1], f'Best: {val_loss[best_epoch-1]:.3f}', color='#6CF527', fontsize=10)
ax.set_xlabel('Epoch', color='white', fontsize=11)
ax.set_ylabel('Loss', color='white', fontsize=11)
ax.set_title('Model Training Progress', color='white', fontsize=14, fontweight='bold', pad=15)
ax.tick_params(colors='#888888', labelsize=9)
for spine in ax.spines.values():
spine.set_color('#333333')
ax.legend(facecolor='#0a0a0f', edgecolor='#333333', labelcolor='white')
ax.set_xlim(1, 100)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Area Chart examples
☕