Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Heatmaps

The following imports have been used to produce the plots below:

#![allow(unused)]
fn main() {
use plotly::common::{ColorScale, ColorScalePalette, Title};
use plotly::contour::Contours;
use plotly::{Contour, HeatMap, Layout, Plot};
use std::f64::consts::PI;
}

The to_inline_html method is used to produce the html plot displayed in this page.

Basic Heatmap

#![allow(unused)]
fn main() {
fn basic_heat_map(show: bool, file_name: &str) {
    let z = vec![vec![1, 20, 30], vec![20, 1, 60], vec![30, 60, 1]];
    let trace = HeatMap::new_z(z)
        .zmin(1.0)
        .zmax(60.0)
        .hover_info(HoverInfo::Text)
        .hover_text_matrix(vec![
            vec!["A", "B", "C"],
            vec!["D", "E", "F"],
            vec!["G", "H", "I"],
        ]);
    let mut plot = Plot::new();
    plot.add_trace(trace);

    let path = write_example_to_html(&plot, file_name);
    if show {
        plot.show_html(path);
    }
}
}