From ed3e4354eceb2c07808afc9c819cd992f2007f6b Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Wed, 3 Dec 2025 15:05:51 +0100 Subject: [PATCH] Trier les heatmaps de couleurs par teinte --- lib/plots/colors_timeline.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/plots/colors_timeline.py b/lib/plots/colors_timeline.py index a339ddd..cf6e95b 100644 --- a/lib/plots/colors_timeline.py +++ b/lib/plots/colors_timeline.py @@ -7,6 +7,7 @@ import matplotlib.pyplot as plt import numpy as np from lib.filesystem import ensure_parent_dir +from lib.color_sort import sort_hex_colors_lab from lib.milestones import load_milestones from lib.rebrickable.stats import read_rows @@ -86,9 +87,11 @@ def build_heatmap_data(rows: Iterable[dict]) -> Tuple[List[int], List[str], np.n for row in rows: key = (row["color_name"], row["color_rgb"], row["is_translucent"]) color_totals[key] = color_totals.get(key, 0) + int(row["quantity_total"]) + ordered_hex = sort_hex_colors_lab({color_rgb for _, color_rgb, _ in color_totals.keys()}) + hex_rank = {hex_value: index for index, hex_value in enumerate(ordered_hex)} sorted_colors = sorted( color_totals.items(), - key=lambda item: (-item[1], item[0][0], item[0][1]), + key=lambda item: (hex_rank[item[0][1]], item[0][2], item[0][0]), ) color_keys = [color for color, _ in sorted_colors] labels = [f"{name} ({'trans' if is_trans == 'true' else 'opaque'})" for name, _, is_trans in color_keys]