Skip to main content

Overview

Theme controls all non-data visual elements of a plot:
  • Background, axes, grid, tick marks
  • Text and legend styling
  • Plot-specific chrome (box medians, violin borders, etc.)
Themes are separate from Palette, which controls data element colors.

Usage

use kuva::prelude::*;

let layout = Layout::auto_from_plots(&plots)
    .with_theme(Theme::dark());

Built-in Themes

Theme::light()

Light background theme (default).
  • Background: white
  • Axes/ticks: black
  • Grid: #ccc
  • Text: black
  • Shows grid by default

Theme::dark()

Dark background theme.
  • Background: #1e1e1e
  • Axes/ticks: #cccccc
  • Grid: #444444
  • Text: #e0e0e0
  • Shows grid by default

Theme::minimal()

Minimal theme with no grid and serif font.
  • Background: white
  • Axes/ticks: black
  • Grid: hidden
  • Text: black
  • Font: serif
  • Legend: no border

Theme::solarized()

Solarized light theme.
  • Background: #fdf6e3
  • Axes/ticks: #586e75
  • Grid: #eee8d5
  • Text: #657b83
  • Shows grid by default

Custom Themes

Create a custom theme by modifying fields:
let mut theme = Theme::dark();
theme.background = "#0d1117".into();
theme.grid_color = "#30363d".into();
theme.show_grid = true;

let layout = Layout::auto_from_plots(&plots)
    .with_theme(theme);

Fields

background
String
Background color
axis_color
String
Color of axis lines
grid_color
String
Color of grid lines
tick_color
String
Color of tick marks
text_color
String
Color of all text (labels, titles, ticks)
legend_bg
String
Legend background color
legend_border
String
Legend border color (use “none” for no border)
pie_leader
String
Color of pie chart leader lines
box_median
String
Color of box plot median line
violin_border
String
Color of violin plot outline
colorbar_border
String
Color of colorbar border
font_family
Option<String>
Font family (e.g., “serif”, “sans-serif”, “monospace”)
show_grid
bool
Whether to show grid lines by default

Source

src/render/theme.rs

Build docs developers (and LLMs) love