When to Use
- Single-cell gene expression: Show % expressing (size) and mean expression (color) per cell type
- Multi-condition experiments: Display two measurements (e.g. effect size and significance) across conditions
- Pathway enrichment: Show gene count (size) and FDR (color) for pathways across datasets
- Pharmacology: Display drug response (size) and toxicity (color) across cell lines
- Any categorical grid: When two continuous variables need simultaneous encoding
Basic Example
Input Modes
Sparse Tuples: with_data
Pass an iterator of (x_cat, y_cat, size, color) tuples. Missing grid positions have no circle drawn.
Dense Matrix: with_matrix
Pass explicit category lists and sizes[row][col] / colors[row][col] matrices. Every grid cell is filled.
Key Methods
Data Input
with_data(iter)
Add data as sparse (x_cat, y_cat, size, color) tuples.
with_matrix(x_cats, y_cats, sizes, colors)
Add data as explicit category lists and dense matrices.
Styling
with_color_map(map: ColorMap)
Set color map for color encoding (default ColorMap::Viridis).
Viridis, Inferno, Grayscale, Custom.
with_max_radius(r: f64)
Set maximum circle radius in pixels (default 12.0).
size value maps to this radius.
with_min_radius(r: f64)
Set minimum circle radius in pixels (default 1.0).
size value maps to this radius.
Range Clamping
with_size_range(min: f64, max: f64)
Clamp size encoding to explicit [min, max] range before normalizing.
min map to min_radius; values above max map to max_radius. Useful for consistent scale across multiple plots.
with_color_range(min: f64, max: f64)
Clamp color encoding to explicit [min, max] range before normalizing.
Legends
with_size_legend(label: impl Into<String>)
Enable size legend in right margin showing representative circle sizes.
with_colorbar(label: impl Into<String>)
Enable colorbar in right margin showing color scale.
Examples
Full Single-Cell Gene Expression
Dense Matrix Input
Size Legend Only
Colorbar Only
Legends
Both legends are optional and independent:- Size legend: Shows representative circle sizes with corresponding values
- Colorbar: Shows color scale mapping data range to colormap