Note
Go to the end to download the full example code.
Proportional symbolsΒΆ
For an absolute quantity (a count), symbol size preserves the magnitude that colour value would flatten. Data: excess deaths among people over 75 during the 2025 heatwaves, by department (Sante publique France, ODISSE).
Hover a circle to read its value.
from pathlib import Path
import pandas as pd
from mappyng import Map, BasemapLayer, ProportionalLayer, VectorLayer
from mappyng.data import load_france_departments, load_france_regions, load_europe
europe = load_europe().to_crs(2154)
regions = load_france_regions().to_crs(2154)
deps = load_france_departments().to_crs(2154)
df = pd.read_csv(Path("data") / "canicule_exces_75_2025.csv", dtype={"code_dep": str})
deps = deps.merge(df, left_on="COD_GEO", right_on="code_dep", how="left")
pts = deps[deps["exces_deces"].notna()].copy()
bbox_metro = [90000, 6040000, 1280000, 7150000]
cartouches = {
0: {"bbox": [-6890454, 1780151, -6799589, 1874186], "crs": 3857,
"cartouche_title": "Guadeloupe", "cartouche_title_size": 7,
"border_radius": 6, "box_shadow": True},
1: {"bbox": [-6826862, 1609607, -6759494, 1685367], "crs": 3857,
"cartouche_title": "Martinique", "cartouche_title_size": 7,
"border_radius": 6, "box_shadow": True},
2: {"bbox": [-6136680, 235261, -5707791, 671780], "crs": 3857,
"cartouche_title": "French Guiana", "cartouche_title_size": 7,
"border_radius": 6, "box_shadow": True},
3: {"bbox": [6136383, -2448160, 6226316, -2366992], "crs": 3857,
"cartouche_title": "Reunion", "cartouche_title_size": 7,
"border_radius": 6, "box_shadow": True},
4: {"bbox": [5006226, -1459183, 5050208, -1416184], "crs": 3857,
"cartouche_title": "Mayotte", "cartouche_title_size": 7,
"border_radius": 6, "box_shadow": True},
}
m = Map(europe, bbox=bbox_metro, width=900, height=1000, padding=25,
facecolor="#eef2e6", border_radius=10,
box_shadow={"dx": 3, "dy": 3, "blur": 6, "opacity": 0.2},
cartouche_params=cartouches, cartouche_spacing=15)
m.add(BasemapLayer())
m.add(VectorLayer(regions, stroke="#4d4d4d", stroke_width=0.2, on_cartouches=True))
m.add_shadow(europe, {"query": "code_pays_iso3=='FRA'", "on_cartouches": True})
m.add(ProportionalLayer(
pts,
column="exces_deces",
fill="#d7301f",
fill_opacity=0.6,
stroke="#7f0000",
legend={"title": "Excess deaths"},
))
m.title("Excess deaths during heatwaves",
subtitle="People over 75, 2025")
m.scale_bar(length=100000, label="100 km", position={"x": 0.46, "y": 0.9},
opacity=0.8)
m.source("Source: Sante publique France (ODISSE)")
# Hover tooltips. The gallery embeds an interactive SVG from this dict; the
# same call also yields a standalone HTML file.
TOOLTIP = {"columns": ["LIB_GEO", "exces_deces"],
"aliases": {"LIB_GEO": "Department", "exces_deces": "Excess deaths"}}
interactive = m.to_interactive(**TOOLTIP)
# interactive.save("proportional.html")
Total running time of the script: (0 minutes 0.275 seconds)