Skip to content

Instantly share code, notes, and snippets.

@MaxGhenis
Created April 20, 2026 13:48
Show Gist options
  • Select an option

  • Save MaxGhenis/f684a0d4ae3f06a5ff917f9e9cf54cfc to your computer and use it in GitHub Desktop.

Select an option

Save MaxGhenis/f684a0d4ae3f06a5ff917f9e9cf54cfc to your computer and use it in GitHub Desktop.
"""Generate hero image for the Madoff fact-check post.
Uses PolicyEngine design tokens (theme.css CSS variables).
See: @policyengine/ui-kit/theme.css
"""
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
from pathlib import Path
# PolicyEngine design tokens (from @policyengine/ui-kit/theme.css)
TEAL = "#319795" # --chart-1 / teal-500 (primary brand, "positive" series)
TEAL_DARK = "#285E61" # --chart-3 / teal-700
GRAY_500 = "#6B7280" # --chart-5 / gray-500 (neutral)
GRAY_200 = "#E2E8F0" # --border / gray-200 (neutral baseline)
FG = "#000000" # --foreground
MUTED_FG = "#4B5563" # gray-600
# Register Inter (downloaded to /tmp/fonts; matplotlib caches by path).
for f in Path("/tmp/fonts").glob("*.ttf"):
fm.fontManager.addfont(str(f))
FONT = "Inter"
plt.rcParams.update({
"font.family": FONT,
"font.size": 12,
"text.usetex": False,
"mathtext.default": "regular",
"axes.edgecolor": GRAY_200,
"axes.labelcolor": MUTED_FG,
"xtick.color": MUTED_FG,
"ytick.color": FG,
})
# Results from wealth_tax_analysis.py against PolicyEngine Enhanced CPS 2026
# (top 1% of fed income+payroll tax, in-between, pays ≤ $0)
bands = [
("Top 100\nnet worth \\$100M–\\$190M", 100.0, 0.0),
("Top 1,000\nnet worth \\$100M–\\$190M", 100.0, 0.0),
("Top 10,000\nnet worth \\$51M–\\$190M", 78.1, 10.3),
("Top 100,000\nnet worth \\$30M–\\$190M", 21.5, 17.4),
("All US households", 1.0, 31.9),
]
fig, ax = plt.subplots(figsize=(12, 6.3), dpi=100)
fig.patch.set_facecolor("white")
labels = [b[0] for b in bands]
top1 = [b[1] for b in bands]
nonpay = [b[2] for b in bands]
mid = [100 - a - b for a, b in zip(top1, nonpay)]
left = [0] * len(bands)
ax.barh(labels, top1, left=left, color=TEAL, edgecolor="white",
label="In top 1% of fed income+payroll tax payers")
left = [a for a in top1]
ax.barh(labels, mid, left=left, color=GRAY_200, edgecolor="white",
label="In between")
left = [a + b for a, b in zip(top1, mid)]
ax.barh(labels, nonpay, left=left, color=GRAY_500, edgecolor="white",
label="Pay ≤ $0 federal income+payroll tax")
# Percent labels on the teal segment where it's wide enough
for i, v in enumerate(top1):
if v >= 6:
ax.text(v / 2, i, f"{v:.1f}%", ha="center", va="center",
color="white", fontsize=11, fontweight="600")
ax.set_xlim(0, 100)
ax.invert_yaxis()
ax.set_xlabel("Share of households in each group (%)", fontsize=11, color=MUTED_FG)
ax.set_title(
"In PolicyEngine's microdata, every one of the 1,000 wealthiest households\n"
"is a top-1% federal taxpayer — none are nonpayers",
fontsize=13, fontweight="600", color=FG, pad=14,
)
ax.legend(loc="upper center", bbox_to_anchor=(0.5, -0.15), ncol=3,
frameon=False, fontsize=10, labelcolor=MUTED_FG)
ax.spines[["top", "right"]].set_visible(False)
ax.spines[["left", "bottom"]].set_color(GRAY_200)
ax.tick_params(axis="y", length=0)
ax.tick_params(axis="x", labelsize=10)
ax.grid(axis="x", alpha=0.3, linewidth=0.5, color=GRAY_200)
ax.set_axisbelow(True)
fig.text(0.99, 0.01, "Source: PolicyEngine Enhanced CPS (2026), SCF-imputed net worth",
ha="right", va="bottom", fontsize=8, color=MUTED_FG)
out = Path("/Users/maxghenis/maxghenis.com/src/content/blog/madoff-billionaire-nonpayers.png")
plt.tight_layout()
plt.savefig(out, dpi=100, bbox_inches="tight", facecolor="white")
print(f"Saved {out} using font: {FONT}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment