spb/traite-evaluation-qc
Public
1#!/usr/bin/env python32"""Figure ch03 — Coût d'usage du logement au Québec, 2001-2026, données RÉELLES (Banque du Canada, Valet : V80691335 taux3hypothécaire affiché 5 ans, BD.CDN.5YR.DQ.YLD obligation 5 ans, V39079 taux directeur ; Statistique Canada 18-10-0004-01 IPC Québec,418-10-0205-01 IPLN Québec), lues dans data/raw (téléchargées le 2026-10-31). Paramètres déclarés : τ = 0,825 % (taxes Ville de5Québec 2026 + scolaire 2026-2027), δ = 2,5 % (entretien, dépréciation, prime de risque : hypothèse pédagogique).6Panneau A : taux nominaux et inflation ; B : taux de coût d'usage u sous deux hypothèses d'anticipation ; C : ratio prix/loyer implicite 1/u.7Sortie : assets/figures/ch03/ch03-fig-cout-usage.pdf"""8import sys, pathlib9ROOT = pathlib.Path(__file__).resolve().parents[3]10sys.path.insert(0, str(ROOT / "analysis/python")); sys.path.insert(0, str(ROOT / "analysis/python/cases"))11import matplotlib.pyplot as plt, matplotlib.dates as mdates12from traite.style import setup, palette, savefig, LARGEUR13import ch03_cycles as cas141516def main():17 setup()18 df = cas.serie_cout_usage()19 fig, (a, b, c) = plt.subplots(3, 1, figsize=(LARGEUR, 6.0), sharex=True)20 a.plot(df.index, df["hyp5"], color=palette.cat[0], label="taux hypothécaire affiché 5 ans (V80691335)")21 a.plot(df.index, df["gdc5"], color=palette.cat[1], label="obligation du Canada 5 ans")22 a.plot(df.index, df["directeur"], color=palette.cat[2], lw=1.2, label="taux directeur (depuis 2009)")23 a.plot(df.index, df["pi"], color=palette.cat[3], lw=1.2, ls="--", label="inflation IPC Québec, 12 mois")24 a.set_ylabel("% par an"); a.legend(fontsize=7, ncol=2, loc="upper center"); a.set_title("A. Taux nominaux et inflation", loc="left"); a.set_ylim(-1, 12.5)25 b.plot(df.index, df["u_ipc"], color=palette.cat[0], label="$u$ avec $g$ = inflation IPC (12 mois)")26 b.plot(df.index, df["u_ipln"], color=palette.cat[1], label="$u$ avec $g$ = croissance IPLN Québec (5 ans)")27 b.axhline(0, color=palette.ink2, lw=0.7)28 b.set_ylabel("% du prix par an"); b.legend(fontsize=7, loc="upper right"); b.set_title("B. Taux de coût d'usage $u = i + \\tau + \\delta - g$", loc="left")29 c.plot(df.index, df["pr_ipc"], color=palette.cat[0], label="$P/R$ = 1/$u$, anticipation IPC")30 c.plot(df.index, df["pr_ipln"].clip(upper=40), color=palette.cat[1], label="$P/R$ = 1/$u$, anticipation IPLN")31 c.set_ylabel("multiple du loyer annuel"); c.set_ylim(5, 40); c.legend(fontsize=7, loc="upper left"); c.set_title("C. Ratio prix/loyer implicite", loc="left")32 last = df.index[-1]33 c.annotate(f"{last:%Y-%m} : {df['pr_ipc'].iloc[-1]:.1f}", xy=(last, df["pr_ipc"].iloc[-1]), xytext=(-60, -14), textcoords="offset points", fontsize=7.5,34 arrowprops=dict(arrowstyle="-", color=palette.ink2, lw=0.6))35 for ax in (a, b, c):36 ax.axvspan(mdates.date2num(__import__("datetime").date(2022, 3, 1)), mdates.date2num(__import__("datetime").date(2023, 7, 31)), color=palette.grid, alpha=0.7, lw=0)37 c.xaxis.set_major_locator(mdates.YearLocator(3)); c.xaxis.set_major_formatter(mdates.DateFormatter("%Y"))38 fig.tight_layout(h_pad=1.0)39 out = savefig(fig, "ch03/ch03-fig-cout-usage.pdf"); print("OK", out)404142if __name__ == "__main__":43 main()44