Quill ðŠķ
A lightweight Rust plotting library for creating simple SVG 2D plots. Quill is designed for simplicity and ease of use, making it perfect for generating basic plots for reports, examples, or any application that needs clean, vector-based visualizations.
Features
- ðĻ Basic Styling: Choose colors, marker types, and line styles
- ð Simple Layouts: Configurable dimensions, titles, axis labels, legends, and grids
- ð§ Builder Pattern: Clean API with method chaining
- ð Multiple Data Series: Support for multiple datasets on a single plot
- ðžïļ SVG Output: Export to SVG files or return as
svg::Documentfor programmatic use - ⥠Lightweight: Minimal dependencies for fast compilation
Quick Start
Add Quill to your Cargo.toml:
[]
= "0.1.0"
Basic Line Plot
use *;
Examples
Line Plot
A simple sine wave visualization with connected points:
use *;
let line_plot = builder
.dimensions
.title
.x_label
.y_label
.legend
.grid
.data
.build;
Scatter Plot
Data points without connecting lines:
use *;
let scatter_plot = builder
.dimensions
.title
.legend
.grid
.data
.build;
Multi-Series Plot
Multiple datasets on the same plot:
use *;
let plot = builder
.dimensions
.title
.x_label
.y_label
.legend
.grid
.data
.build;
Investment Growth Data
Points with different line styles:
use *;
let plot = builder
.dimensions
.title
.x_label
.y_label
.x_range
.legend
.grid
.font
.data
.build;
API Overview
Plot Builder
Configure your plot with the builder pattern:
builder
.dimensions // Plot size
.title // Chart title
.x_label // X-axis label
.y_label // Y-axis label
.x_range // X-axis range (Auto or Manual)
.y_range // Y-axis range (Auto or Manual)
.legend // Legend position
.grid // Grid style
.font // Font family
.margin // Plot margins
.data // Data series
.build
Series Builder
Define data series with markers and line styling:
builder
.name // Legend name
.color // Line/marker color
.data // Data points (f32, f64, i32, or i64 tuples)
.marker // Point markers
.marker_size // Marker size
.line // Line style (or Line::None for scatter)
.build
Note the Colors are derived from the pigment crate. More information at pigment.
Output Options
// Save to SVG file
plot.to_svg.unwrap;
// Get SVG document for programmatic use
let svg_doc: Document = plot.to_document;
Available Options
Markers
Marker::None- No markersMarker::Circle- Circular pointsMarker::Square- Square pointsMarker::Cross- Cross markers
Line Styles
Line::Solid- Solid linesLine::Dashed- Dashed linesLine::Dotted- Dotted linesLine::None- No connecting lines
Grid Styles
Grid::Solid- Solid grid linesGrid::Dashed- Dashed grid linesGrid::Dotted- Dotted grid linesGrid::None- No grid
Legend Positions
Legend::TopLeftInsideLegend::TopRightInsideLegend::TopRightOutsideLegend::BottomLeftInsideLegend::BottomRightInsideLegend::BottomRightOutsideLegend::LeftCenterInsideLegend::RightCenterInsideLegend::RightCenterOutsideLegend::TopCenterLegend::BottomCenterLegend::None
Dependencies
Quill has minimal dependencies to keep your build fast:
bon- For builder patternspigment- For color handlingsvg- For SVG generation
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.