colors#
Default category-color mappings for openplaces standard columns.
Keys are label strings as stored in parquet files after ingestion (i.e. post-labels-CSV remapping, not raw source codes).
Functions#
|
Return the best-matching color palette for a set of category values. |
Module Contents#
- openplaces.viz.colors.match_palette(values, col_name=None, weights=None, threshold=0.5)#
Return the best-matching color palette for a set of category values.
Tries matches in order:
Exact column-name key lookup.
Any palette key is a substring of the column name.
Frequency-weighted coverage: fraction of total weight (row count) whose category label has a defined color, using
weightsif provided, otherwise falling back to unweighted unique-label coverage.
- Parameters:
values (iterable) – The category labels present in the plot (e.g.
widths.columns).col_name (str, optional) – Column name hint; checked first for an exact or substring key match.
weights (array-like, optional) – Total weight (e.g. row count) for each value in
values, in the same order. When provided, coverage is computed as the fraction of total weight that falls in palette-covered categories, making the match robust to many rare/uncovered categories.threshold (float) – Minimum coverage required for a value-based match.
- Returns:
Matching
{label: color}palette, orNoneif no good match.- Return type:
dict or None