Overview
Kuva provides 20+ plot types for scientific visualization. Each plot type has its own builder API with type-specific configuration methods. All plots implementInto<Plot> for collection into Vec<Plot>.
Creating Plots
Basic Pattern
All plots follow a consistent builder pattern:Converting to Plot Enum
Plots must be converted to thePlot enum for rendering:
Plot enum (src/render/plots.rs:30-56) wraps all plot types:
Plot Type Categories
Point Plots
ScatterPlot - X/Y points with optional error bars, trend lines, and confidence bandsCircle, Square, Triangle, Diamond, Cross, Plus
StripPlot - Categorical X with jittered Y values
Line Plots
LinePlot - Connected line segments with optional fill and bandsDistribution Plots
Histogram - Binned frequency distributionBar Plots
BarPlot - Grouped or stacked barsGrid Plots
Heatmap - 2D color-coded matrixPlot Methods
Common Builder Methods
Most plot types support these common methods:Data Methods
Data can be provided in multiple formats:Legend Integration
Plots with.with_legend() automatically appear in the legend:
Plot Bounds
Each plot type implements abounds() method that returns Option<((f64, f64), (f64, f64))> representing ((x_min, x_max), (y_min, y_max)).
The Layout::auto_from_plots() function calls bounds() on each plot to compute axis ranges (src/render/plots.rs:144-503).
Special cases:
- Category plots (Bar, Box, Violin) use integer positions with 0.5 padding
- Grid plots (Heatmap, Histogram2D) align cells to integer boundaries
- Pixel-space plots (Chord, Sankey, PhyloTree) return dummy bounds
Colorbar Integration
Plots with continuous color mappings automatically show a colorbar:HeatmapHistogram2DDotPlot(when using color encoding)Contour(when filled)
Multiple Plots
Combine different plot types by collecting intoVec<Plot>:
Source Code References
- Plot enum:
src/render/plots.rs:30-56 - Plot bounds:
src/render/plots.rs:144-503 - Into implementations:
src/render/plots.rs:58-82 - Individual plot types:
src/plot/*.rs
Next Steps
- Layout System - Configuring axes and appearance
- Theme System - Styling plots
- Plot Types - Detailed documentation for each plot type