Skip to content

Commit 9adcffd

Browse files
🎉 static viz: population over the long run (#5602)
1 parent 5742928 commit 9adcffd

8 files changed

Lines changed: 7185 additions & 360 deletions

dag/static_viz.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ steps:
22
# World population growth visualization
33
export://static_viz/population/2026-01-26/world_population_growth:
44
- data://garden/demography/2024-07-15/population
5+
6+
# World population long-run visualization (10,000 BCE - 2100)
7+
export://static_viz/population/2026-02-02/world_population_long_run:
8+
- data://grapher/demography/2024-07-15/population
9+
- data://grapher/demography/2025-10-22/life_expectancy

etl/helpers.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,27 @@ def create_explorer_legacy(
913913

914914
return explorer
915915

916+
def export_fig(self, fig, filename: str, extensions: list[str], **kwargs) -> None:
917+
"""Export a matplotlib figure to multiple formats.
918+
919+
:param fig: The matplotlib figure to export.
920+
:param filename: The base filename (without extension).
921+
:param extensions: List of file extensions to export (e.g., ["png", "svg"]).
922+
:param kwargs: Additional keyword arguments to pass to fig.savefig().
923+
"""
924+
for ext in extensions:
925+
path = self.directory / f"{filename}.{ext}"
926+
save_kwargs = {
927+
"fname": path,
928+
"format": ext,
929+
**kwargs,
930+
}
931+
if ext == "svg":
932+
# Remove date metadata for SVG to keep files clean
933+
save_kwargs["metadata"] = {"Date": None}
934+
fig.savefig(**save_kwargs)
935+
self.log.info(f"Saved chart to {path}")
936+
916937

917938
def _match_dependencies(pattern: str, dependencies: set[str]) -> set[str]:
918939
regex = re.compile(pattern)

0 commit comments

Comments
 (0)