Trier les heatmaps de couleurs par teinte
This commit is contained in:
parent
b0b5202ed4
commit
ed3e4354ec
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user