SPB Git
2.5 KB · 43 lines python
1#!/usr/bin/env python32"""Figure ch08 — carte synthétique des zones de « Val-Fictif » (DONNÉES SYNTHÉTIQUES) : 400 lots, cinq zones,3îlot rezoné H1 → H2 (hachures) et ventes de l'îlot postérieures au rezonage (points).4Sortie : assets/figures/ch08/ch08-fig-carte-zones.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 matplotlib.pyplot as plt9from matplotlib.patches import Rectangle, Patch10from matplotlib.lines import Line2D11from traite.style import setup, palette, savefig, LARGEUR12import ch08_zonage as cas1314ZONES = {"H1": ("H1 — habitation unifamiliale", 0), "H2": ("H2 — habitation 2 à 4 logements", 1), "H3": ("H3 — habitation multifamiliale", 2),15         "C": ("C — commerce et usages mixtes", 3), "P": ("P — parc et institutionnel", 4)}161718def main():19    setup()20    lots, ventes = cas.charger_ou_generer(ecrire=False)21    fig, ax = plt.subplots(figsize=(LARGEUR, 3.9))22    for _, L in lots.iterrows():23        c = palette.cat[ZONES[L["zone_initiale"]][1]]24        ax.add_patch(Rectangle((L["x"], L["y"]), 1, 1, facecolor=c, edgecolor=palette.surface, linewidth=0.5, alpha=0.85))25        if L["rezone"]:26            ax.add_patch(Rectangle((L["x"], L["y"]), 1, 1, facecolor="none", edgecolor=palette.ink, hatch="////", linewidth=0.0))27    # contour de l'îlot rezoné28    ax.add_patch(Rectangle((7, 8), 3, 12, facecolor="none", edgecolor=palette.ink, linewidth=1.4))29    tr = ventes[ventes["traite_post"]].merge(lots[["id_lot", "x", "y"]], on="id_lot")30    ax.scatter(tr["x"] + 0.5, tr["y"] + 0.5, s=14, color=palette.ink, zorder=5, linewidths=0)31    ax.text(8.5, 20.35, "îlot rezoné H1 → H2\n(1er janv. 2025)", ha="center", va="bottom", fontsize=7.5, color=palette.ink)32    ax.text(10, 1.5, "boulevard (zone C)", ha="center", va="center", fontsize=7.5, color=palette.surface, fontweight="bold")33    ax.set_xlim(0, 20); ax.set_ylim(0, 22.2); ax.set_aspect("equal"); ax.axis("off")34    handles = [Patch(facecolor=palette.cat[i], label=lab) for lab, i in ZONES.values()]35    handles += [Patch(facecolor="none", edgecolor=palette.ink, hatch="////", label="lots rezonés (traités)"),36                Line2D([0], [0], marker="o", color="none", markerfacecolor=palette.ink, markersize=4, label="ventes de l'îlot après T0")]37    ax.legend(handles=handles, loc="center left", bbox_to_anchor=(1.01, 0.5), fontsize=7.5, frameon=False)38    savefig(fig, "ch08/ch08-fig-carte-zones.pdf")394041if __name__ == "__main__":42    main()43
Files · 2eb2bf4e67f754808bae5090a9e53eab37149ddb
Menu

Theme