Theme Functions#
ARGscape provides functions for working with visualization themes programmatically.
argscape.get_theme()#
Retrieve a built-in theme by name.
import argscape
theme = argscape.get_theme("paper")
print(theme.name) # "paper"
print(theme.background) # "#ffffff"
print(theme.nodes.sample) # "#2563eb"
Parameters#
Parameter |
Type |
Description |
|---|---|---|
|
|
Theme name: |
Returns#
A Theme object containing all color definitions.
Raises#
ValueError- If the theme name is not recognized
argscape.list_themes()#
Get a list of all available theme names.
>>> argscape.list_themes()
['tskit', 'liquid', 'grayscale', 'paper']
Returns#
list[str] - List of available theme names.
argscape.customize_theme()#
Create a custom theme by overriding specific colors from a base theme.
import argscape
# Create custom theme based on 'paper'
my_theme = argscape.customize_theme(
"paper",
sample_color="#e63946",
edge_color="#457b9d",
)
Full Function Signature
def customize_theme(
base: str | Theme = "liquid",
*,
# Node colors
sample_color: str | None = None,
internal_color: str | None = None,
root_color: str | None = None,
# Edge colors
edge_color: str | None = None,
# Other colors
background_color: str | None = None,
mutation_color: str | None = None,
text_color: str | None = None,
) -> Theme
Parameters#
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Base theme to customize. Can be a theme name or an existing |
|
|
|
Override color for sample (leaf) nodes. Hex string (e.g., |
|
|
|
Override color for internal nodes. |
|
|
|
Override color for root nodes. |
|
|
|
Override color for edges. |
|
|
|
Override background color. |
|
|
|
Override color for mutation markers. |
|
|
|
Override color for text labels. |
Returns#
A new Theme object with the specified overrides applied.
Examples#
Basic customization:
import argscape
# Red samples on paper theme
my_theme = argscape.customize_theme(
"paper",
sample_color="#e63946",
)
# Use with visualize() via color parameters
viz = argscape.visualize(ts, theme="paper", sample_color="#e63946")
Multiple color overrides:
# Nature-inspired palette on grayscale base
forest_theme = argscape.customize_theme(
"grayscale",
sample_color="#2a9d8f", # Teal samples
internal_color="#e9c46a", # Gold internal nodes
root_color="#e76f51", # Coral roots
edge_color="#264653", # Dark teal edges
mutation_color="#f4a261", # Orange mutations
)
Chaining customizations:
# Start from a custom theme
base = argscape.customize_theme("paper", sample_color="#e63946")
# Further customize
final = argscape.customize_theme(
base,
edge_color="#1d3557",
background_color="#f1faee",
)
Theme Object#
The Theme class is a frozen dataclass containing all visualization colors.
Attributes#
Attribute |
Type |
Description |
|---|---|---|
|
|
Theme identifier |
|
|
Background color |
|
|
Node color settings |
|
|
Edge color settings |
|
|
Primary text color |
|
|
Secondary text color |
|
|
Grid line color |
|
|
Mutation marker color |
|
|
Unknown mutation marker color |
NodeColors#
Attribute |
Description |
|---|---|
|
Sample (leaf) node color |
|
Internal node color |
|
Root node color |
|
Cluster indicator color |
|
Selected node highlight color |
EdgeColors#
Attribute |
Description |
|---|---|
|
Default edge color |
|
Highlighted edge color |
|
Dimmed/inactive edge color |
Methods#
to_dict()#
Serialize the theme to a dictionary (useful for JSON export).
theme = argscape.get_theme("paper")
theme_dict = theme.to_dict()
Built-in Themes#
liquid (default)#
Light, Apple-inspired theme with glassmorphism effects.
theme = argscape.get_theme("liquid")
# Background: #f5f5f7 (Apple light gray)
# Samples: #14E2A8 (ARGscape green)
# Internal: #94A3B8 (Slate)
Best for: General use, web display, Jupyter notebooks
tskit#
Dark theme with cyan and green accents matching the original ARGscape look.
theme = argscape.get_theme("tskit")
# Background: #03303E (Dark teal)
# Samples: #14E2A8 (Pale green)
# Internal: #60A0B7 (Light blue)
# Roots: #38BDF8 (Cyan)
Best for: Presentations, screen viewing, dark environments
grayscale#
Black and white theme for journals that don’t accept color figures.
theme = argscape.get_theme("grayscale")
# Background: #ffffff
# All elements in shades of gray
Best for: Journal publications (no color), print without color
paper#
High-contrast colors optimized for print publications.
theme = argscape.get_theme("paper")
# Background: #ffffff
# Samples: #2563eb (Blue)
# Internal: #6b7280 (Gray)
# Roots: #dc2626 (Red)
# Mutations: #ea580c (Orange)
Best for: Color journal figures, posters, presentations
Using Custom Themes#
You can pass a custom Theme object directly to visualize():
import argscape
# Create a custom theme
my_theme = argscape.customize_theme(
"paper",
sample_color="#e63946",
edge_color="#457b9d",
)
# Pass the theme object directly
viz = argscape.visualize(ts, theme=my_theme)
viz.show()
Alternatively, use inline color parameters for quick overrides:
# Inline color overrides (no need to create theme object)
viz = argscape.visualize(
ts,
theme="paper", # Base theme name
sample_color="#e63946", # Override specific colors
edge_color="#457b9d",
)
Both approaches produce the same result. Use customize_theme() when you want to:
Reuse the same custom theme across multiple visualizations
Inspect or log the theme colors programmatically
Build themes incrementally through chaining
See Also#
argscape.visualize() - Main visualization function with color parameters
Themes - Tutorial on themes and styling
First Visualization - Getting started with visualizations