spb/traite-evaluation-qc
Public
1#!/usr/bin/env python32"""Figure ch13 — composition de l'évaluation imposable uniformisée 2026 (MAMH, richesse foncière uniformisée, CC BY 4.0 ;3données RÉELLES, data/raw/mamh_rfu_2026/RFU-2026.csv) pour Montréal, Québec et Gatineau.4Sortie : assets/figures/ch13/ch13-fig-rfu.pdf"""5import sys, pathlib6ROOT = pathlib.Path(__file__).resolve().parents[3]7sys.path.insert(0, str(ROOT / "analysis/python")); sys.path.insert(0, str(ROOT / "analysis/python/cases"))8import numpy as np, matplotlib.pyplot as plt9from traite.style import setup, palette, savefig, LARGEUR10import ch13_sources as cas111213def main():14 setup()15 rf = cas.rfu_2026(); villes = ["Montréal", "Québec", "Gatineau"]16 cats = list(cas.POSTES_RFU.values())17 fig, ax = plt.subplots(figsize=(LARGEUR, 2.6))18 left = np.zeros(len(villes))19 for i, c in enumerate(cats):20 vals = np.array([rf["villes"][v]["parts_pct"][c] for v in villes])21 ax.barh(villes, vals, left=left, color=palette.cat[i], label=c, height=0.6)22 for y, (l, v) in enumerate(zip(left, vals)):23 if v >= 6: ax.text(l + v / 2, y, f"{v:.0f} %", ha="center", va="center", fontsize=7.5, color=palette.ink if i in (1, 2, 5) else "white")24 left += vals25 for y, v in enumerate(villes):26 ax.text(101, y, f"{rf['villes'][v]['imposable_uniformise']/1e9:.0f} G$", va="center", fontsize=7.5, color=palette.ink2)27 ax.set_xlim(0, 112); ax.set_xlabel("Part de l'évaluation imposable uniformisée 2026 (%)")28 ax.invert_yaxis(); ax.legend(fontsize=7, ncol=3, loc="upper center", bbox_to_anchor=(0.5, -0.28), frameon=False)29 ax.grid(axis="y", visible=False)30 out = savefig(fig, "ch13/ch13-fig-rfu.pdf"); print("OK", out)313233if __name__ == "__main__":34 main()35