spb/traite-evaluation-qc
Public
1#!/usr/bin/env python32"""Figure ch07 — trajectoire du fonds de prévoyance sur 25 ans selon trois cotisations (DONNÉES SYNTHÉTIQUES).3Sortie : assets/figures/ch07/ch07-fig-fonds-prevoyance.pdf"""4import sys, pathlib5ROOT = pathlib.Path(__file__).resolve().parents[3]6sys.path.insert(0, str(ROOT / "analysis/python")); sys.path.insert(0, str(ROOT / "analysis/python/cases"))7import numpy as np, matplotlib.pyplot as plt8from traite.style import setup, palette, savefig, LARGEUR, fmt_dollars9import ch07_servitudes_copro as cas1011def main():12 setup()13 A = cas.cotisation_seuil(); regle = 0.005 * cas.VALEUR_RECONSTRUCTION14 t_act, t_regle, t_star = cas.trajectoire(cas.COTISATION_ACTUELLE), cas.trajectoire(regle), cas.trajectoire(A)15 ans = np.arange(0, cas.HORIZON + 1) + 202616 fig, ax = plt.subplots(figsize=(LARGEUR, 3.8))17 ax.bar(ans[1:], -t_star["D"][1:], color=palette.grid, width=0.7, label="Réparations majeures prévues (dépenses, indexées à 2,5 %)")18 ax.plot(ans, t_act["F"], color=palette.cat[3], lw=1.8, label=f"Cotisation actuelle : {cas.COTISATION_ACTUELLE:,.0f} $ (indexée)".replace(",", " "))19 ax.plot(ans, t_regle["F"], color=palette.cat[2], lw=1.8, ls="--", label=f"Règle du 0@5 % de la valeur de reconstruction : {regle:,.0f} $".replace(",", " ").replace("@", ","))20 ax.plot(ans, t_star["F"], color=palette.cat[0], lw=2.0, label=f"Cotisation de seuil A* : {A:,.0f} $ (indexée)".replace(",", " "))21 ax.axhline(0, color=palette.ink2, lw=0.8)22 ax.yaxis.set_major_formatter(plt.FuncFormatter(fmt_dollars))23 ax.set_xlabel("Année"); ax.set_ylabel("Solde du fonds en fin d'année")24 ax.set_xlim(2025.5, 2051.5)25 ax.legend(loc="upper center", bbox_to_anchor=(0.45, -0.17), ncol=2, fontsize=7.2)26 ax.annotate("an 14 : fenêtres\n(solde A* = 0)", xy=(2039, 0), xytext=(2043.5, -80000), fontsize=7.5, color=palette.ink2,27 arrowprops=dict(arrowstyle="-", color=palette.ink2, lw=0.7))28 out = savefig(fig, "ch07/ch07-fig-fonds-prevoyance.pdf"); print("OK", out)2930if __name__ == "__main__":31 main()32