Expand description
Heatman is for generating heatmaps from tabular data. The library provides core functionality for data processing and heatmap generation, while the CLI handles user input and interaction.
§Examples
§Example 1: Generating a heatmap from a CSV file
The simple use case available on examples/generate_heatmap_from_csv.rs.
use heatman::{Heatmap, Data, DataLoader};
use image::{ImageBuffer, Rgba};
let data = DataLoader::load("testdata/sample.csv") // load data from CSV file
.expect("Failed to load data from CSV");
let context = Heatmap::new(cells, 10); // create heatmap context with pixel size of 10
let image: ImageBuffer<Rgba<u8>, Vec<u8>> = context.into(); // convert heatmap context into an image
image.save("example1.png") // save the generated heatmap image
.expect("Failed to save heatmap image");§Example 2: Generating a scaler
Generate a scaler image with height of 20 pixels, which can be used as a reference for interpreting the heatmap colors.
The example is available on examples/generate_scaler.rs.
use heatman::{Heatmap, ScalerBuilder};
use image::{ImageBuffer, Rgba};
let data = ScalerBuilder::build_with(20); // create scaler data with height of 20 pixels
let context = Heatmap::new(data, 1); // create heatmap context with pixel size of 1 (each cell corresponds to 1 pixel)
let image: ImageBuffer<Rgba<u8>, Vec<u8>> = context.into();
image.save("scaler.png") // save the generated scaler image
.expect("Failed to save scaler image");§Example 3: Specify the order of rows and columns
let data = DataLoader::load("testdata/jaccard.csv")
.expect("Failed to load data from CSV");
let order = Order::load_symmetric("testdata/header.csv")
.expect("Failed to load order from file");
let reordered_data = data.reorder(&order);
let cells: Data<Rgba<u8>> = reordered_data.into();
let context = Heatmap::new(cells, 10);
let image: ImageBuffer<Rgba<u8>, Vec<u8>> = context.into();
image.save("jaccard.png")
.expect("Failed to save heatmap image");Structs§
- Data
- Represents a matrix of data with optional row and column headers.
- Data
Loader - Load data from a CSV file, scaling values to the specified range.
- Heatmap
- Context for generating heatmaps, containing the data and pixel size.
- Scaler
Builder - Generates a scaler image data with the specified height.
Enums§
- Error
- Represents errors that can occur during heatman operations.
- Order
- Represents the order of rows and columns in a heatmap.
Functions§
- convert
- Converts a floating-point value to an RGBA color.
Type Aliases§
- Result
- A specialized Result type for heatman operations.