| Crates.io | xyplot |
| lib.rs | xyplot |
| version | 0.1.8 |
| created_at | 2025-02-23 16:39:02.612875+00 |
| updated_at | 2025-02-26 16:40:09.238651+00 |
| description | A tool for plotting images in a grid with labels |
| homepage | |
| repository | https://github.com/rakki194/xyplot |
| max_upload_size | |
| id | 1566486 |
| size | 59,307 |
A Rust command-line tool for plotting images in a grid layout with optional labels. Built on top of the imx library.
cargo install xyplot
# Basic usage with just images
xyplot image1.jpg image2.jpg image3.jpg
# Specify number of rows
xyplot image1.jpg image2.jpg image3.jpg image4.jpg --rows 2
# With row labels (supports multiline text with \n)
xyplot image1.jpg image2.jpg image3.jpg image4.jpg \
--rows 2 \
--row-labels "Row 1\nDetails" "Row 2\nMore Info"
# With column labels (supports multiline text with \n)
xyplot image1.jpg image2.jpg image3.jpg image4.jpg \
--rows 2 \
--column-labels "Col 1\nFirst" "Col 2\nSecond"
# Configure column label alignment
xyplot image1.jpg image2.jpg \
--column-labels "Col 1" "Col 2" \
--column-label-alignment start
# Configure row label alignment
xyplot image1.jpg image2.jpg \
--row-labels "Row 1" "Row 2" \
--row-label-alignment end
# Adjust padding for labels
xyplot image1.jpg image2.jpg \
--column-labels "Header\nSubheader" "Col 2\nDetails" \
--top-padding 80 \
--left-padding 100
# Specify output file
xyplot image1.jpg image2.jpg --output result.jpg
# Enable layout debugging
xyplot image1.jpg image2.jpg --debug
Both row and column labels can be aligned independently using the --column-label-alignment and --row-label-alignment options:
start: Align labels at the start (left for columns, top for rows)center: Center labels (default)end: Align labels at the end (right for columns, bottom for rows)You can use \n in your labels to create multiple lines:
# Two-line column labels
xyplot image1.jpg image2.jpg \
--column-labels "Title\nSubtitle" "Header\nDetails"
# Three-line row labels
xyplot image1.jpg image2.jpg \
--rows 2 \
--row-labels "Section 1\nDetails\nMore Info" "Section 2\nNotes\nExtra"
The padding will automatically adjust to accommodate the multiline text, but you can also specify custom padding:
# Custom padding for multiline labels
xyplot image1.jpg image2.jpg \
--column-labels "Title\nSubtitle" \
--row-labels "Section\nDetails" \
--top-padding 80 \
--left-padding 100
The --debug flag enables a powerful layout visualization feature that helps understand and debug how images and labels are positioned in the grid.
When you use the --debug flag, xyplot will generate two files:
output.jpg)output_debug.jpg)The debug visualization uses color coding to show different elements:
# Debug visualization with multiline labels
xyplot image1.jpg image2.jpg image3.jpg image4.jpg \
--rows 2 \
--row-labels "Row 1\nDetails" "Row 2\nMore Info" \
--column-labels "Col 1\nFirst" "Col 2\nSecond" \
--debug
The debug visualization helps you:
This is particularly useful when:
If you want to use the plotting functionality in your own Rust project, consider using the imx library directly:
use imx::{PlotConfig, create_plot, LabelAlignment};
use std::path::PathBuf;
fn main() -> anyhow::Result<()> {
let config = PlotConfig {
images: vec![PathBuf::from("image1.jpg"), PathBuf::from("image2.jpg")],
output: PathBuf::from("output.jpg"),
rows: 1,
row_labels: vec!["Row 1\nDetails".to_string()],
column_labels: vec!["Col 1\nFirst".to_string(), "Col 2\nSecond".to_string()],
column_label_alignment: LabelAlignment::Center,
row_label_alignment: LabelAlignment::Start,
top_padding: 60,
left_padding: 80,
debug_mode: false,
};
create_plot(&config)?;
Ok(())
}
Clone the repository
Install dependencies:
cargo build
Run the tests:
cargo test
MIT License