#!/usr/bin/env python3 """Ch. 30, figure « loyers » : trajectoire du revenu brut potentiel contractuel (indexé au taux TAL + relocation de 15 % des logements par an au loyer de marché) et du RBP au marché, cas 3 (DONNÉES SYNTHÉTIQUES). Sortie : ch30-fig-loyers.pdf.""" from __future__ import annotations import sys, pathlib sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter from traite.style import setup, palette, savefig, LARGEUR, fmt_milliers from cases import ch30_dcf as c def main(): setup() r = c.base(); p = r["projection"]; h = r["hyp"] fig, ax = plt.subplots(figsize=(LARGEUR, 3.1)) x = p["exercice"].values ax.fill_between(x, p["rbp"] / 1000, p["rbp_marche"] / 1000, color=palette.grid, alpha=0.9, label="Écart au marché (rattrapage)") ax.plot(x, p["rbp_marche"] / 1000, color=palette.cat[1], marker="s", ms=3.5, label=f"RBP au loyer de marché (+{h['croissance_loyers_marche']*100:.1f} %/an)") ax.plot(x, p["rbp"] / 1000, color=palette.cat[0], marker="o", ms=3.5, label=f"RBP contractuel projeté (TAL {h['croissance_loyers_contrat']*100:.1f} % + rotation {h['rotation_annuelle']*100:.0f} %)") # contractuel sans rotation (indexation TAL seule) pour référence sans = [p["rbp"].iloc[0] * (1 + h["croissance_loyers_contrat"]) ** k / 1000 for k in range(len(x))] ax.plot(x, sans, color=palette.cat[0], ls=":", lw=1.2, label="RBP contractuel sans relocation (indexation TAL seule)") e0 = (p["rbp_marche"].iloc[0] - p["rbp"].iloc[0]); eT = (p["rbp_marche"].iloc[-1] - p["rbp"].iloc[-1]) ax.annotate(f"écart {fmt_milliers(e0)} $ ({e0/p['rbp_marche'].iloc[0]*100:.1f} %)", xy=(x[0], (p["rbp"].iloc[0] + p["rbp_marche"].iloc[0]) / 2000), xytext=(x[0] + 0.3, 215), fontsize=8, arrowprops=dict(arrowstyle="-", color=palette.ink2, lw=0.7)) ax.annotate(f"écart {fmt_milliers(eT)} $ ({eT/p['rbp_marche'].iloc[-1]*100:.1f} %)", xy=(x[-1], (p["rbp"].iloc[-1] + p["rbp_marche"].iloc[-1]) / 2000), xytext=(x[-1] - 3.6, 262), fontsize=8, arrowprops=dict(arrowstyle="-", color=palette.ink2, lw=0.7)) ax.set_ylabel("Revenu brut potentiel (milliers de $)"); ax.set_xlabel("Exercice") ax.set_xticks(x); ax.yaxis.set_major_formatter(FuncFormatter(lambda v, q: fmt_milliers(v))) ax.set_ylim(top=p["rbp_marche"].max() / 1000 * 1.04) ax.legend(loc="upper left", fontsize=7.5) savefig(fig, "ch30/ch30-fig-loyers.pdf") if __name__ == "__main__": main()