SPB Git
2.6 KB · 37 lines python
1#!/usr/bin/env python32"""Figure ch42 — charges annuelles normalisées des huit fractions (ch. 7) et part de chacune dans une cotisation spéciale égale au déficit3de capitalisation du fonds de prévoyance (DONNÉES SYNTHÉTIQUES, immeuble fictif du ch. 7).4Sortie : assets/figures/ch42/ch42-fig-cotisation-speciale.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, LARGEUR, fmt_dollars10import ch42_copro as cas1112def main():13    setup()14    cs = cas.cotisation_speciale(); rep = cs["rep"]; qp = cas.QP15    noms = [f"{n} ({s:.0f} m², q = {q:.4f})".replace(".", ",") for n, s, q in zip(qp["noms"], qp["superficies"], qp["q"])]16    y = np.arange(len(noms)); h = 0.3617    fig, ax = plt.subplots(figsize=(LARGEUR, 3.9))18    gauche = np.zeros(len(noms))19    blocs = [("Charges courantes", rep["par_fraction_courantes"], palette.cat[0]), ("Fonds de prévoyance (A*)", rep["par_fraction_fonds"], palette.cat[1]),20             ("Fonds d'auto assurance", rep["par_fraction_auto"], palette.cat[2]), ("Stationnement (usage restreint)", rep["par_fraction_restreint"], palette.cat[3])]21    for lab, vals, col in blocs:22        ax.barh(y - h / 2, vals, left=gauche, height=h, color=col, label=lab + " — annuel"); gauche += vals23    ax.barh(y + h / 2, cs["par_fraction"], height=h, color=palette.surface, edgecolor=palette.cat[4], hatch="////", lw=0.8,24            label=f"Cotisation spéciale unique = q_i × {cs['montant']:,.0f} $ (déficit du fonds)".replace(",", " "))25    for yi, tot, part, ratio in zip(y, rep["par_fraction_total"], cs["par_fraction"], cs["ratio_annees"]):26        ax.text(tot + 300, yi - h / 2, f"{tot:,.0f} $/an".replace(",", " "), va="center", fontsize=7.2, color=palette.ink)27        ax.text(part + 300, yi + h / 2, f"{part:,.0f} $ (= {ratio:.1f} années de charges)".replace(",", " ").replace(".", ","), va="center", fontsize=7.2, color=palette.ink)28    ax.set_yticks(y); ax.set_yticklabels(noms); ax.invert_yaxis()29    ax.xaxis.set_major_formatter(plt.FuncFormatter(fmt_dollars)); ax.set_xlim(0, cs["par_fraction"].max() * 1.75)30    ax.set_xlabel("Dollars de 2026 (données synthétiques, immeuble fictif de huit fractions)")31    ax.grid(axis="y", visible=False)32    ax.legend(loc="upper center", bbox_to_anchor=(0.45, -0.17), ncol=2, fontsize=7.2)33    out = savefig(fig, "ch42/ch42-fig-cotisation-speciale.pdf"); print("OK", out)3435if __name__ == "__main__":36    main()37
Files · 81b1896e4502a619cf4f142fb8809253a8ff0bf3
Menu

Theme