Area Chart

Proportional Stacked Area

100% stacked area with clean R aesthetics

Output
Proportional Stacked Area
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
x = np.arange(2015, 2026)
cat_a = np.array([30, 32, 35, 38, 40, 42, 45, 48, 50, 52, 55])
cat_b = np.array([25, 26, 25, 24, 25, 26, 25, 24, 23, 22, 20])
cat_c = np.array([20, 19, 18, 18, 17, 16, 15, 15, 14, 14, 13])
cat_d = 100 - cat_a - cat_b - cat_c

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

ax.stackplot(x, cat_a, cat_b, cat_c, cat_d,
             colors=['#F5276C', '#27D3F5', '#6CF527', '#F5B027'],
             labels=['Category A', 'Category B', 'Category C', 'Category D'],
             alpha=0.85)

ax.set_xlabel('Year', color='white', fontsize=11, fontweight='500')
ax.set_ylabel('Proportion (%)', color='white', fontsize=11, fontweight='500')
ax.set_title('Market Share Evolution', color='white', fontsize=13, fontweight='600', pad=15)
ax.tick_params(colors='#888888', labelsize=9)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#333333')
ax.spines['bottom'].set_color('#333333')
ax.set_xlim(2015, 2025)
ax.set_ylim(0, 100)
ax.legend(facecolor='#0a0a0f', edgecolor='#333333', labelcolor='white', 
          loc='center left', bbox_to_anchor=(1.02, 0.5))

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support