#!/usr/bin/env python3 """Figure ch07 — trajectoire du fonds de prévoyance sur 25 ans selon trois cotisations (DONNÉES SYNTHÉTIQUES). Sortie : assets/figures/ch07/ch07-fig-fonds-prevoyance.pdf""" import sys, pathlib ROOT = pathlib.Path(__file__).resolve().parents[3] sys.path.insert(0, str(ROOT / "analysis/python")); sys.path.insert(0, str(ROOT / "analysis/python/cases")) import numpy as np, matplotlib.pyplot as plt from traite.style import setup, palette, savefig, LARGEUR, fmt_dollars import ch07_servitudes_copro as cas def main(): setup() A = cas.cotisation_seuil(); regle = 0.005 * cas.VALEUR_RECONSTRUCTION t_act, t_regle, t_star = cas.trajectoire(cas.COTISATION_ACTUELLE), cas.trajectoire(regle), cas.trajectoire(A) ans = np.arange(0, cas.HORIZON + 1) + 2026 fig, ax = plt.subplots(figsize=(LARGEUR, 3.6)) 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 %)") ax.plot(ans, t_act["F"], color=palette.cat[3], lw=1.8, label=f"Cotisation actuelle : {cas.COTISATION_ACTUELLE:,.0f} $ (indexée)".replace(",", " ")) 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(",", " ")) ax.plot(ans, t_star["F"], color=palette.cat[0], lw=2.0, label=f"Cotisation de seuil A* : {A:,.0f} $ (indexée)".replace(",", " ")) ax.axhline(0, color=palette.ink2, lw=0.8) ax.yaxis.set_major_formatter(plt.FuncFormatter(fmt_dollars)) ax.set_xlabel("Année"); ax.set_ylabel("Solde du fonds en fin d'année") ax.set_xlim(2025.5, 2051.5) ax.legend(loc="upper left", fontsize=7.2) ax.annotate("an 14 : fenêtres\n(solde A* = 0)", xy=(2039, 0), xytext=(2041.5, 120000), fontsize=7.5, color=palette.ink2, arrowprops=dict(arrowstyle="-", color=palette.ink2, lw=0.7)) out = savefig(fig, "ch07/ch07-fig-fonds-prevoyance.pdf"); print("OK", out) if __name__ == "__main__": main()