1
etude_lego_jurassic_world/scripts/plot_minifig_new_characters.py

41 lines
1.3 KiB
Python

"""Trace le nombre de nouveaux personnages introduits par an (hors figurants)."""
from pathlib import Path
from lib.plots.minifig_characters import plot_new_characters_per_year
from lib.rebrickable.minifig_characters import (
aggregate_new_characters_by_year,
load_minifigs_by_set,
load_sets_enriched,
write_new_characters_by_year,
)
MINIFIGS_BY_SET_PATH = Path("data/intermediate/minifigs_by_set.csv")
SETS_ENRICHED_PATH = Path("data/intermediate/sets_enriched.csv")
COUNTS_PATH = Path("data/intermediate/minifig_new_characters_by_year.csv")
DESTINATION_PATH = Path("figures/step23/minifig_new_characters_per_year.png")
MILESTONES_PATH = Path("config/milestones.csv")
EXCLUDED_CHARACTERS = ["Figurant"]
START_YEAR = 2015
END_YEAR = 2025
def main() -> None:
"""Construit le total de nouveaux personnages par année et trace le graphique."""
minifigs = load_minifigs_by_set(MINIFIGS_BY_SET_PATH)
sets_years = load_sets_enriched(SETS_ENRICHED_PATH)
counts = aggregate_new_characters_by_year(
minifigs,
sets_years,
excluded_characters=EXCLUDED_CHARACTERS,
start_year=START_YEAR,
end_year=END_YEAR,
)
write_new_characters_by_year(COUNTS_PATH, counts)
plot_new_characters_per_year(COUNTS_PATH, MILESTONES_PATH, DESTINATION_PATH, START_YEAR, END_YEAR)
if __name__ == "__main__":
main()