ColorMap after normalizing values to [0.0, 1.0] relative to the data range. A colorbar is always shown in the right margin.
Constructor
new()
Create a heatmap with default settings.
Returns: Heatmap
Defaults:
- Viridis color map
- No value overlay
- No labels
Data Loading
with_data()
Set the grid data.
Accepts any iterable of iterables of numeric values. The outer iterator produces rows (top to bottom); the inner iterator produces columns (left to right). All rows must have the same number of columns.
Self
Labels
with_labels()
Store row and column label strings in the struct.
Row label strings
Column label strings
Self
Note: These labels are not rendered automatically. To display them on the axes, pass them to Layout::with_y_categories (rows) and Layout::with_x_categories (columns) when building the layout.
Styling
with_color_map()
Set the color map used to encode cell values.
Color map applied after normalizing values to
[0.0, 1.0]. Options: ColorMap::Viridis (default), ColorMap::Inferno, ColorMap::Grayscale, or ColorMap::Custom(Arc<Fn>)Self
Default: ColorMap::Viridis
with_values()
Overlay numeric values inside each cell.
Returns: Self
Values are formatted to two decimal places and centered in the cell. Most useful for small grids where the text remains legible.
Legend
with_legend()
Attach a legend label to this heatmap.
Legend label text
Self
Complete Example
Public Fields
Rows × columns grid of values. All rows must have the same length.
Optional row labels — stored in the struct but rendered via
Layout::with_y_categoriesOptional column labels — stored in the struct but rendered via
Layout::with_x_categoriesColor map applied after normalizing values to
[0.0, 1.0]. Defaults to ColorMap::ViridisWhen
true, each cell displays its raw numeric value as textOptional legend label