AGENT SKILL

colormap-theory

Choosing colormaps scientifically — perceptual uniformity, color-vision deficiency, and matching map to data type.

License 许可
MIT
所属仓库
TanNhatCMS/jarvis
最近更新
2026-11-07
Stars
★ 0
Forks
1

01 前言 Front Matter

name
colormap-theory
category
scientific
description
Choosing colormaps scientifically — perceptual uniformity, color-vision deficiency, and matching map to data type.

03 SKILL.md 正文

Overview

A colormap is a visual encoding function: data value → color. Bad ones (rainbow/jet) create false structure and hide real structure; good ones are perceptually uniform and readable by everyone. This skill covers matching colormap type to data (sequential, diverging, cyclic, qualitative), perceptual uniformity, color-vision-deficiency safety, and practical selection in matplotlib, Plotly, and beyond.

When to use

  • Choosing a colormap for a heatmap, contour plot, or 3D surface
  • Fixing a figure that uses rainbow/jet
  • Encoding signed data (anomalies, differences) with a diverging map
  • Making figures readable for colorblind viewers and in grayscale
  • Designing a custom colormap for a specific variable

Core concepts

  • Perceptual uniformity: equal data steps should look like equal color steps — measured in CIELAB space; viridis, cividis, batlow, and ColorBrewer maps qualify; jet/rainbow emphatically don't (their sharp yellow/cyan bands invent boundaries).

  • Map types: sequential (low→high, one hue ramp: viridis, plasma, Blues), diverging (two ramps around a meaningful center: RdBu, Vik, coolwarm — center must be meaningful, e.g., zero anomaly), cyclic (phase/angle: twilight, hsv — ends must match), qualitative/categorical (distinct hues: Tab10, Set2 — never a continuous map for categories).

  • Lightness carries the information: the human visual system reads data primarily through lightness variation — a good sequential map is monotonic in lightness; test by converting to grayscale.

  • Color-vision deficiency: ~8% of men have red–green deficiency — avoid red–green encodings for critical distinctions; cividis was designed for maximal CVD safety; simulate with CVD simulators before publishing.

  • Background matters: dark-background figures need different map tuning than white-background ones; transparency/alpha encodings interact with the background color.

  • The data's dynamic range: skewed data need nonlinear normalization (log, power-law, asinh) more than they need a fancy map — fix the mapping before blaming the colors.

  • CIELAB and perceptual distance: professional colormap design happens in perceptually uniform spaces (CIELAB, CIECAM02) — equal steps in data become equal ΔE steps in color; RGB interpolation is not perceptually uniform.

  • The rainbow's specific sins: non-monotonic lightness (bright yellow/cyan bands), false contours at hue boundaries, and high-frequency name boundaries — each creates structure the data doesn't have.

  • Bivariate colormaps: encoding two variables in one map (e.g., value + uncertainty) — powerful but hard to read; use only with a clear legend and when the joint distribution is the message.

Practical workflow

1. Classify your data, then choose

Data Map type Examples
Sequential, zero-based Sequential viridis, plasma, batlow, Blues
Diverging around meaningful center Diverging RdBu_r, Vik, coolwarm
Phase / orientation Cyclic twilight, phase
Categories Qualitative Tab10, Set2, Okabe-Ito

2. Apply correctly

import matplotlib.pyplot as plt
from matplotlib.colors import CenteredNorm, LogNorm, PowerNorm
# Diverging data around zero: center the map explicitly
plt.imshow(anomaly, cmap="RdBu_r", norm=CenteredNorm(vcenter=0))
# Skewed positive data: log or power-law normalization
plt.imshow(counts, cmap="viridis", norm=LogNorm())
  1. Set vmin/vmax (or norm) deliberately — autoscaling to outliers wastes the dynamic range; consider robust limits (percentiles) with out-of-range marking.
  2. For diverging maps, center exactly on the meaningful midpoint — an off-center "diverging" map lies.
  3. Always include a colorbar with labeled ticks and units — a heatmap without a scale is decoration.

3. Test accessibility

  1. Convert to grayscale: is the structure still visible? (If not, the map fails its primary job.)
  2. Simulate deuteranopia/protanopia/tritanopia — check that critical distinctions survive.
  3. Print in black and white if the venue might — many readers still do.

4. Go beyond defaults when needed

  1. For publication series, define one palette per variable and reuse it — consistency builds reader intuition.
  2. Build custom maps with perceptually uniform interpolation (viscm, cmaputil) rather than hand-picking RGB stops.
  3. Document the colormap and normalization in the caption or methods — reproducibility includes the visual encoding.

5. Design a custom colormap

  1. Define the data mapping first (sequential/diverging/cyclic, normalization, center) — the map serves the mapping, not vice versa.
  2. Build in a perceptual colorspace: interpolate in CIELAB between chosen control colors, enforcing monotonic lightness for sequential maps.
  3. Test with viscm-style diagnostics: perceptual-delta plots should be flat (uniform), and test images (sine waves, wedges) should show no false banding — iterate until clean.

Common pitfalls

  • Rainbow/jet: non-uniform, creates false contours, CVD-hostile — the single most common visualization error in science; replace on sight.
  • Diverging map without a meaningful center: a diverging map centered at an arbitrary value implies structure that isn't there.
  • Continuous map for categories: implies ordering and interpolation between classes that don't exist.
  • Autoscale to outliers: one hot pixel flattens everything else — use robust limits.
  • Missing colorbar: no scale, no units, no interpretation — always label.
  • 3D surface + bad map: perspective distortion plus non-uniform color is double deception — prefer 2D heatmaps with good maps for quantitative reading.
  • Alpha as a second encoding: transparency interacts with background color unpredictably — overlapping transparent marks create false dark spots read as data.
  • Colormap applied to already-encoded data: double-encoding (e.g., contour lines + colormap of the same variable) adds ink without information — pick one encoding per variable.

04 同仓库更多 Skills

TanNhatCMS
TanNhatCMS/jarvis

web-scrape

Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

design-taste-frontend

tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

test-driven-development

Use when implementing any feature or bugfix, before writing implementation code

★ 0
TanNhatCMS
TanNhatCMS/jarvis

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

★ 0
TanNhatCMS
TanNhatCMS/jarvis

requesting-code-review

Use when completing tasks, implementing major features, or before merging to verify work meets requirements

★ 0
TanNhatCMS
TanNhatCMS/jarvis

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

★ 0