pub struct HeatMap {
pub traces: Vec<Box<dyn Trace + 'static>>,
pub layout: Layout,
}Expand description
A structure representing a heat map.
The HeatMap struct enables the creation of heat map visualizations with options for color scaling,
axis customization, legend adjustments, and data value formatting. Users can customize the color
scale, adjust the color bar, and set titles for the plot and axes, as well as format ticks and scales
for improved data readability.
§Arguments
data- A reference to theDataFramecontaining the data to be plotted.x- A string slice specifying the column name for x-axis values.y- A string slice specifying the column name for y-axis values.z- A string slice specifying the column name for z-axis values, which are represented by the color intensity.auto_color_scale- An optional boolean for enabling automatic color scaling based on data.color_bar- An optional reference to aColorBarstruct for customizing the color bar appearance.color_scale- An optionalPaletteenum for specifying the color scale (e.g., Viridis).reverse_scale- An optional boolean to reverse the color scale direction.show_scale- An optional boolean to display the color scale on the plot.plot_title- An optionalTextstruct for setting the title of the plot.x_title- An optionalTextstruct for labeling the x-axis.y_title- An optionalTextstruct for labeling the y-axis.x_axis- An optional reference to anAxisstruct for customizing x-axis appearance.y_axis- An optional reference to anAxisstruct for customizing y-axis appearance.
§Example
use polars::prelude::*;
use plotlars::{ColorBar, HeatMap, Palette, Plot, Text, ValueExponent};
let dataset = LazyCsvReader::new(PlPath::new("data/heatmap.csv"))
.finish()
.unwrap()
.collect()
.unwrap();
HeatMap::builder()
.data(&dataset)
.x("x")
.y("y")
.z("z")
.color_bar(
&ColorBar::new()
.length(290)
.value_exponent(ValueExponent::None)
.separate_thousands(true)
.tick_length(5)
.tick_step(2500.0)
)
.plot_title(
Text::from("Heat Map")
.font("Arial")
.size(18)
)
.color_scale(Palette::Viridis)
.build()
.plot();
Fields§
§traces: Vec<Box<dyn Trace + 'static>>§layout: LayoutImplementations§
Source§impl HeatMap
impl HeatMap
Sourcepub fn builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>() -> HeatMapBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>
pub fn builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>() -> HeatMapBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>
Examples found in repository?
examples/heatmap.rs (line 12)
5fn main() {
6 let dataset = LazyCsvReader::new(PlPath::new("data/heatmap.csv"))
7 .finish()
8 .unwrap()
9 .collect()
10 .unwrap();
11
12 HeatMap::builder()
13 .data(&dataset)
14 .x("x")
15 .y("y")
16 .z("z")
17 .color_bar(
18 &ColorBar::new()
19 .length(290)
20 .value_exponent(ValueExponent::None)
21 .separate_thousands(true)
22 .tick_length(5)
23 .tick_step(2500.0),
24 )
25 .plot_title(Text::from("Heat Map").font("Arial").size(18))
26 .color_scale(Palette::Viridis)
27 .build()
28 .plot();
29}Trait Implementations§
Auto Trait Implementations§
impl Freeze for HeatMap
impl !RefUnwindSafe for HeatMap
impl !Send for HeatMap
impl !Sync for HeatMap
impl Unpin for HeatMap
impl !UnwindSafe for HeatMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more