Skip to content

Support dynamic color scaling in plots using mean and standard deviation #91

@EH-MLS

Description

@EH-MLS

Problem

Currently, the plot color mapping in Tab-right assumes that error or metric values are normalized to the [0, 1] range or uses min/max normalization. This can be problematic when the data contains outliers or when consistent color meaning across plots is required. Users may want a more robust, data-driven scaling method for color mapping.

Proposed Solution

Add an option to perform dynamic color scaling using the average (mean) and standard deviation (std) of the metric values. Specifically:

  • Allow users to select a scaling method (e.g., "minmax" or "std") in plotting functions.
  • When using the "std" method, set the color scale to cover [mean - kstd, mean + kstd] (default k=2), and normalize/clamp values accordingly before mapping to the colormap.
  • Provide documentation/examples on how to use the new scaling option.

Benefits

  • More robust color mapping (less sensitive to outliers)
  • Consistent interpretation of colors across different plots
  • Greater flexibility for users with varying metric ranges

Example Implementation

def normalize_scores(scores, method="std", k=2):
    if method == "std":
        mean = np.mean(scores)
        std = np.std(scores)
        vmin = mean - k * std
        vmax = mean + k * std
    elif method == "minmax":
        vmin = np.min(scores)
        vmax = np.max(scores)
    else:
        raise ValueError("Unknown method")
    clipped = np.clip(scores, vmin, vmax)
    return (clipped - vmin) / (vmax - vmin + 1e-8)

Additional Context

This feature would help users who want more control over how plot colors reflect their metric distributions, especially for metrics not naturally in the [0, 1] range.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions