pub struct Heatmap { /* private fields */ }Expand description
A heatmap.
Implementations§
Source§impl Heatmap
impl Heatmap
Sourcepub fn new(values: Vec<f64>, cols: usize) -> Self
pub fn new(values: Vec<f64>, cols: usize) -> Self
Create a 2D heatmap. Will automatically infer number of rows.
valuescontains magnitude of each tile. The alignment is row by row.colsis the number of columns (i.e. the length of each row).values.len()should be a multiple ofcols.
Example: To display this
| – | – | | 0.0 | 0.1 | | 0.3 | 0.4 |
pass values = vec![0.0, 0.1, 0.3, 0.4] and cols = 2.
If parameters are invalid (e.g., cols is zero, values is empty, or
values.len() is not divisible by cols), an empty heatmap is created.
Sourcepub fn resolution(self, resolution: usize) -> Self
pub fn resolution(self, resolution: usize) -> Self
Set the resolution of the color palette.
Higher resolution means smoother color transitions. Default is 128.
Sourcepub fn palette(self, base_colors: &[Color32]) -> Self
pub fn palette(self, base_colors: &[Color32]) -> Self
Set color palette by specifying base colors from low to high
Sourcepub fn range(self, min: f64, max: f64) -> Self
pub fn range(self, min: f64, max: f64) -> Self
Specify custom range of values to map onto color palette.
minand everything smaller will be the first color on the color palette.maxand everything greater will be the last color on the color palette.
Sourcepub fn formatter(self, formatter: Box<dyn Fn(f64) -> String>) -> Self
pub fn formatter(self, formatter: Box<dyn Fn(f64) -> String>) -> Self
Add a custom way to format an element. Can be used to display a set number of decimals or custom labels.
Sourcepub fn custom_mapping(self, custom_mapping: Box<dyn Fn(f64) -> Color32>) -> Self
pub fn custom_mapping(self, custom_mapping: Box<dyn Fn(f64) -> Color32>) -> Self
Add a custom way to map values to a color.
Sourcepub fn show_labels(self, en: bool) -> Self
pub fn show_labels(self, en: bool) -> Self
Show labels for each tile in heatmap. Defaults to ‘true’
Sourcepub fn at(self, pos: PlotPoint) -> Self
pub fn at(self, pos: PlotPoint) -> Self
Place lower left corner of heatmap at pos. Default is (0.0, 0.0)
Sourcepub fn name(self, name: impl ToString) -> Self
pub fn name(self, name: impl ToString) -> Self
Name of this heatmap.
This name will show up in the plot legend, if legends are turned on. Multiple heatmaps may share the same name, in which case they will also share an entry in the legend.
Sourcepub fn tile_size(self, x: f32, y: f32) -> Self
pub fn tile_size(self, x: f32, y: f32) -> Self
Manually set width and height of tiles in plot coordinate space.