Colors and Colormaps¶
This page covers practical usage: picking colors, mixing them, interpolating gradients, and using colormaps. For full visual catalogs, jump to the Colors, Palettes, or Colormaps catalogs under Design System.
Named colors¶
dartwork-mpl ships its own curated palette — dc.* (“dartwork color”)
— and registers six third-party design systems alongside it for
cross-team consistency. Use any of them anywhere matplotlib accepts a
color.
Prefix |
Library |
Example |
|---|---|---|
|
dartwork Color (recommended) — 20 families × 10 perceptual steps, plus Octave as |
|
|
OpenColor |
|
|
Tailwind CSS |
|
|
Material Design |
|
|
Ant Design |
|
|
Chakra UI |
|
|
Primer (GitHub) |
|
Start with
dc.*for new figures — the palettes are tuned for publication-ready output. Reach for the third-party prefixes when you need to match an external brand or design system.The
dc.*namespace also holds 43 continuous colormaps plus the two Octave cycle colormaps — see the Colormap catalog. Colormap names likedc.auroraonly work ascmap=arguments, not ascolor=strings; the named-colors above are the ones you pass tocolor=.
import matplotlib.pyplot as plt
import dartwork_mpl as dm
dm.style.use("presentation")
fig, ax = plt.subplots(figsize=dm.figsize("8cm", "wide"))
ax.plot([0, 1, 2], [1, 2, 1.5], marker="o", color="dc.green2", label="dc.green2")
ax.plot([0, 1, 2], [1.2, 1.6, 2.1], marker="s", color="dc.teal3", label="dc.teal3")
highlight = dm.mix_colors("dc.orange1", "white", alpha=0.45)
ax.fill_between([0, 1, 2], 0.9, 1.3, color=highlight, label="Mixed shade")
muted_line = dm.pseudo_alpha("dc.violet3", alpha=0.65, background="white")
ax.plot([0, 1, 2], [0.8, 1.1, 1.4], color=muted_line, label="Pseudo alpha")
ax.legend()
dm.simple_layout(fig)
To choose a series palette visually, use the
Palettes explorer. It previews Octave, curated
qualitative sets, family samples, B&W/CVD checks, and copyable
dm.set_colors(...) / dm.colors(..., n=...) calls.
Once you’ve picked a set, apply it in your own script:
import matplotlib as mpl
from cycler import cycler
dm.style.use("report") # base preset (font, line widths, spines, ...)
mpl.rcParams["axes.prop_cycle"] = cycler(color=[
"dc.teal3", "dc.teal1", "dc.teal5",
"dc.teal0", "dc.teal2", "dc.teal4",
])
Picking a dc.* swatch¶
The dc.* surface is 19 chromatic hue families plus gray, each with 10
perceptually equalized steps. Index 0 is the light end and index 9 is the dark
end. For unrelated categories use Octave via dm.set_colors() or
dc.octave; for related tones pick a family and sample the steps you need.
Palette |
Use it for |
|---|---|
|
Octave, for everyday unrelated categories |
|
Cool analytical series and ordered data |
|
Positive/negative states and status colors |
|
Warm emphasis, thresholds, and call-outs |
|
Editorial accents and qualitative groups |
|
Grid lines, baselines, secondary fills |
|
Diverging ± data — change, correlation |
|
Semantic highlight token |
→ The full token catalog lives on Colors; the series explorer lives on Palettes.
Coming from oc.*? A rough drop-in mapping:
If you were reaching for… |
Try… |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Color class¶
For most plots, named color strings like "dc.teal3" are all you need. When
you need to programmatically adjust hue, saturation, or lightness — or
interpolate between colors in a perceptually uniform space — use the Color
class:
import dartwork_mpl as dm
color = dm.oklch(0.7, 0.15, 150) # OKLCH (L, C, h°)
color.oklch.C *= 1.2 # boost chroma in-place
print(color.to_hex()) # '#...'
→ Full guide: Color class & manipulation — constructors, views, interpolation, and custom colormaps.
Exploring Available Colors¶
dartwork-mpl provides utilities to discover and explore available color families:
import dartwork_mpl as dm
# List Model B family records
families = dm.list_colors()
print(families[:2]) # [{'name': 'amber', 'kind': 'sequential', ...}, ...]
# Fetch a registered colormap or a designed discrete list
cmap = dm.colors("aurora")
cols = dm.colors("blue_red", n=5)
# Preview specific families
dm.show_colors(names=["blue", "blue_red"], n=5)
# Classify a colormap by type (takes a Colormap object)
import matplotlib as mpl
from dartwork_mpl.diagnostics import classify_cmap
cmap_type = classify_cmap(mpl.colormaps['dc.aurora'])
print(cmap_type) # 'Multi-Hue'
Color interpolation¶
import dartwork_mpl as dm
# Perceptual interpolation between colors (OKLCH by default)
palette = dm.cspace('#FF6B6B', '#4ECDC4', n=5, space='oklch')
for i, c in enumerate(palette):
ax.bar(i, 1, color=c.to_hex())
# Also supports 'oklab' and 'rgb' spaces
gradient = dm.cspace(dm.color('dc.red1'), dm.color('dc.teal3'), n=10)
Why OKLCH matters: Interpolating in RGB produces muddy, desaturated midtones. OKLCH maintains perceptual uniformity — every step looks equally spaced to the human eye:
Colormaps¶
dartwork-mpl bundles custom colormaps prefixed with dc. — curated for
perceptually uniform gradients. They work like any matplotlib colormap:
import matplotlib.pyplot as plt
import dartwork_mpl as dm
from dartwork_mpl.diagnostics import classify_cmap
cmap = plt.colormaps["dc.aurora"]
print(cmap.name) # 'dc.aurora'
print(classify_cmap(cmap)) # 'Multi-Hue' (tells you the type)
Add _r to reverse any colormap (e.g., dc.aurora_r). Browse all available
colormaps on the Colormaps page.
See also¶
Next → Layout and Typography — physical-width geometry, aspect tokens, and
simple_layoutDesign System → Colors / Palettes / Colormaps / Color class — the visual catalogs
Color sources:
asset/color/*.txt+ Tailwind/Material/Ant/Chakra/Primer/opencolor JSON