Overview
Kuva separates visual styling into two systems:- Themes control plot chrome (axes, grid, background, text)
- Palettes provide color sequences for multi-element plots
Theme System
TheTheme struct (src/render/theme.rs:1-98) controls all non-data colors:
Built-in Themes
Kuva provides four built-in themes:Light (Default)
- White background
- Black axes and text
- Light gray grid (
#ccc) - Best for printed documents and presentations
Dark
- Dark gray background (
#1e1e1e) - Light gray axes and text (
#cccccc,#e0e0e0) - Dark grid (
#444444) - Ideal for dark-mode interfaces and terminals
Minimal
- White background
- Black axes and text
- Very light grid (
#e0e0e0) - No legend border
- Serif font family
- Grid disabled by default
- Best for publication-quality figures
Solarized
- Solarized Light base colors
- Background:
#fdf6e3 - Accent:
#586e75 - Text:
#657b83 - Popular among developers
Custom Themes
Create custom themes by constructing theTheme struct directly:
"red"), hex ("#ff0000"), or rgb ("rgb(255,0,0)").
Theme Application
Themes are applied during scene generation (src/render/render.rs:126-129):- Axes:
axis_color - Grid lines:
grid_color - Tick marks:
tick_color - All text:
text_color - Legend background/border:
legend_bg,legend_border
Palette System
ThePalette struct (src/render/palette.rs:3-185) provides sequences of colors for multi-element plots:
Colorblind-Safe Palettes
Wong (Okabe-Ito) - 8 colors
Paul Tol Palettes
Bright - 7 colors, high contrastIBM Design Language - 5 colors
By Colorblind Condition
Convenience methods that map to recommended palettes:General-Purpose Palettes
Category10 (Default) - 10 colors
Pastel - 10 colors
Bold - 10 colors
Custom Palettes
Palette Usage
Palettes are applied to multi-element plots:- BarPlot with multiple bars per group
- Line/Scatter when multiple plots share a layout
- PiePlot slices
- StackedAreaPlot series
- Chord/Sankey nodes
.with_color() setting:
Palette Iteration
Access palette colors programmatically:Color Maps
For continuous color mappings (heatmaps, contours), useColorMap from the plot types:
Combining Themes and Palettes
- Theme controls plot infrastructure
- Palette controls data representation
Accessibility Best Practices
Colorblind Safety
-
Use colorblind-safe palettes for categorical data:
-
Combine color with other visual channels (shape, size, line style):
- Test with simulations: Use tools like Coblis to preview plots.
High Contrast
Dark Mode
Source Code References
- Theme struct:
src/render/theme.rs:1-98 - Palette struct:
src/render/palette.rs:3-185 - Theme application:
src/render/render.rs:126-129
Next Steps
- Layout System - Applying themes and palettes
- Architecture Overview - Rendering pipeline
- Plot Types - Per-plot color configuration