Treemap
Investment Portfolio Allocation
Dark-themed treemap displaying investment portfolio distribution across asset classes including stocks, bonds, real estate, and alternatives.
Output
Python
import matplotlib.pyplot as plt
import squarify
import numpy as np
# Portfolio allocation (in thousands)
labels = ['US Stocks', 'Int\'l Stocks', 'Bonds', 'Real Estate', 'Crypto',
'Commodities', 'Cash', 'Private Equity']
sizes = [350, 180, 220, 120, 45, 35, 80, 70]
total = sum(sizes)
# Calculate percentages
pct = [s/total*100 for s in sizes]
# CLAUDE.md colors - finance theme
colors = ['#27D3F5', '#276CF5', '#6CF527', '#F5B027', '#F5276C',
'#F54927', '#27F5B0', '#5314E6']
fig, ax = plt.subplots(figsize=(12, 8), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
squarify.plot(sizes=sizes,
label=[f'{l}\n${s}K ({p:.1f}%)' for l, s, p in zip(labels, sizes, pct)],
color=colors, alpha=0.85, ax=ax,
text_kwargs={'fontsize': 10, 'color': 'white', 'fontweight': 'bold'})
ax.axis('off')
ax.set_title(f'Investment Portfolio - ${total/1000:.1f}M Total',
fontsize=18, color='#f8fafc', fontweight='bold', pad=20)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Part-to-Whole
☕