Skip to main content

Heatmap

Struct Heatmap 

Source
pub struct Heatmap { /* private fields */ }
Expand description

A heatmap.

Implementations§

Source§

impl Heatmap

Source

pub fn new(values: Vec<f64>, cols: usize) -> Self

Create a 2D heatmap. Will automatically infer number of rows.

  • values contains magnitude of each tile. The alignment is row by row.
  • cols is the number of columns (i.e. the length of each row).
  • values.len() should be a multiple of cols.

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.

Source

pub fn resolution(self, resolution: usize) -> Self

Set the resolution of the color palette.

Higher resolution means smoother color transitions. Default is 128.

Source

pub fn palette(self, base_colors: &[Color32]) -> Self

Set color palette by specifying base colors from low to high

Source

pub fn range(self, min: f64, max: f64) -> Self

Specify custom range of values to map onto color palette.

  • min and everything smaller will be the first color on the color palette.
  • max and everything greater will be the last color on the color palette.
Source

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.

Source

pub fn custom_mapping(self, custom_mapping: Box<dyn Fn(f64) -> Color32>) -> Self

Add a custom way to map values to a color.

Source

pub fn show_labels(self, en: bool) -> Self

Show labels for each tile in heatmap. Defaults to ‘true’

Source

pub fn at(self, pos: PlotPoint) -> Self

Place lower left corner of heatmap at pos. Default is (0.0, 0.0)

Source

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.

Source

pub fn tile_size(self, x: f32, y: f32) -> Self

Manually set width and height of tiles in plot coordinate space.

Source

pub fn size(self, x: f32, y: f32) -> Self

Set size of heatmap in plot coordinate space. Will adjust the heatmap tile size in plot coordinate space.

Source

pub fn highlight(self, highlight: bool) -> Self

Highlight all plot elements.

Trait Implementations§

Source§

impl PartialEq for Heatmap

Source§

fn eq(&self, other: &Self) -> bool

manual implementation of PartialEq because formatter and color mapping do not impl PartialEq.

NOTE: custom_mapping and formatter are ignored

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PlotItem for Heatmap

Source§

fn shapes(&self, ui: &Ui, transform: &PlotTransform, shapes: &mut Vec<Shape>)

Generate shapes to be drawn in the plot.
Source§

fn initialize(&mut self, _x_range: RangeInclusive<f64>)

For plot-items which are generated based on x values (plotting functions).
Source§

fn name(&self) -> &str

Returns the name of the plot item.
Source§

fn color(&self) -> Color32

Returns the color of the plot item.
Source§

fn highlight(&mut self)

Highlight the plot item.
Source§

fn highlighted(&self) -> bool

Returns whether the plot item is highlighted.
Source§

fn geometry(&self) -> PlotGeometry<'_>

Returns the geometry of the plot item.
Source§

fn bounds(&self) -> PlotBounds

Returns the bounds of the plot item.
Source§

fn find_closest( &self, point: Pos2, transform: &PlotTransform, ) -> Option<ClosestElem>

Find the closest element in the plot item to the given point.
Source§

fn on_hover( &self, _plot_area_response: &Response, elem: ClosestElem, shapes: &mut Vec<Shape>, _cursors: &mut Vec<Cursor>, plot: &PlotConfig<'_>, _: &Option<LabelFormatter<'_>>, )

Handle hover events for the plot item.
Source§

fn base(&self) -> &PlotItemBase

Returns a reference to the base data of the plot item.
Source§

fn base_mut(&mut self) -> &mut PlotItemBase

Returns a mutable reference to the base data of the plot item.
Source§

fn allow_hover(&self) -> bool

Can the user hover this item?
Source§

fn id(&self) -> Id

Returns the ID of the plot item.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.