Expand description
BLAND — pure-Rust technical drawing.
A library for paper-ready, monochrome, hatch-patterned plots in the visual tradition of 1960s-80s engineering reports. Output is SVG — resolution-independent, prints clean on any printer, embeds cleanly into LaTeX, PDF pipelines, and HTML documents.
§Quick start
use bland::{Figure, PaperSize, Stroke};
let xs: Vec<f64> = (0..=100).map(|i| i as f64 / 10.0).collect();
let ys: Vec<f64> = xs.iter().map(|t| (-t / 4.0).exp() * t.cos()).collect();
let env: Vec<f64> = xs.iter().map(|t| (-t / 4.0).exp()).collect();
let fig = Figure::new()
.size(PaperSize::A5Landscape)
.title("Damped oscillation")
.xlabel("t [s]")
.ylabel("x(t)")
.line(&xs, &ys, |s| s.label("response"))
.line(&xs, &env, |s| s.label("envelope").stroke(Stroke::Dashed))
.hline(0.0, |s| s.stroke(Stroke::Dotted))
.legend_top_right();
std::fs::write("oscillation.svg", fig.to_svg()).unwrap();§Why monochrome?
- Prints clean. Plots look the same on a laser printer, a color printer, and a photocopy. No “figure unreadable in proceedings” surprises.
- Accessible by default. Hatching, stroke dashing, and marker shape distinguish series — so plots survive grayscale rendering and are legible to readers with color vision deficiency.
§Plot gallery
§Histograms with hatched fills
§Grouped bar charts
§Heatmaps with monochrome ramps
§Iso-line contours
§Box plots with computed Tukey fences
§Vector fields
§Polar coordinates
§Smith chart
§Geographic basemaps
§Lunar maria
§Features
- Series: line, scatter, bar (grouped), area, histogram, heatmap, polygon, error bars, box plots, stem plots, quiver / vector fields, contour iso-lines, reference rules.
- Hatch patterns: 15 presets — diagonals, crosshatch, dots, brick,
zigzag, checker. Build your own via
Hatch::DEFAULT_RAMPfor heatmap shading. - Markers: 12 presets, alternating open / filled / cross variants.
- Stroke dashes: solid, dashed, dotted, dash-dot, long-dash, fine.
- Paper presets: A4, A5, Letter, Legal, Square — portrait & landscape.
- Themes:
Theme::report_1972(serif),Theme::blueprint(monospace),Theme::gazette(newspaper). - Engineering
TitleBlockwith project / drawn-by / date / scale / sheet / revision. - Annotations: in-data text and arrows with anti-overlap halos.
- Linear and log axes with nice-rounded tick placement.
- Projections: polar, Smith, Mercator, equirectangular.
- Built-in basemaps: Earth coastlines & borders (Natural Earth
1:110m, optional 1:50m via the
high-res-basemapsfeature), reference parallels, lunar maria. - Multi-panel layouts via
multi_panel. - Composite helpers:
bode,qq_plot. - Pure Rust, zero dependencies.
Re-exports§
pub use basemaps::Basemap;pub use basemaps::BasemapOpts;pub use basemaps::Resolution;
Modules§
Structs§
- Area
Opts - BarOpts
- Bode
Opts - Options for
bode. - BoxPlot
Opts - BoxStats
- Box-plot summary: quartiles plus Tukey-fence whisker endpoints.
min/maxare the inlier whisker endpoints, not the raw extrema — extreme observations are returned inoutliers. - Contour
Opts - Error
BarOpts - Figure
- The plot document. Build with
Figure::new()and chain methods. - Graticule
Opts - Configuration for
graticule. - Heatmap
Opts - Per-call options for
Figure::heatmap. - Histogram
Opts - Hline
Opts - Line
Opts - Per-call options for
Figure::line. - Panel
Grid Opts - Grid layout configuration for
multi_panel. - Polar
Grid Opts - Options for
Figure::polar_grid. - Polygon
Opts - QqOpts
- Options for
qq_plot. - Quiver
Opts - Scatter
Opts - Smith
Grid Opts - Options for
Figure::smith_grid. - Stem
Opts - Theme
- A theme is a bag of typographic, geometric, and stroke defaults.
Every figure carries one. Use
Theme::report_1972,Theme::blueprint, orTheme::gazettefor the built-in presets, then mutate fields directly to derive variants. - Title
Block - Vline
Opts
Enums§
- Axes
Style - Whether the figure draws axis lines / ticks at all.
- BinStrategy
- Strategy for picking the number of bins when
bin_edgesis not set. - Clip
- Plot-area clip shape.
- Colorbar
Position - Position for a colorbar attached to a heatmap.
- Err
- Per-point error: either symmetric half-width or
(lower, upper). - Grid
Style - Hatch
- Hatch pattern preset.
- Legend
Position - Marker
- Normalize
- Normalization mode for histogram bin values.
- Origin
- Paper
Size - Built-in paper presets (dimensions in pixels at 96 DPI).
- Projection
- Coordinate projection applied to series points before scaling.
- Stroke
- Dash preset for a stroked element.
- Text
Anchor - Tick
Direction - Tick mark direction relative to the plotting frame.
- Title
Block Position - Title
Case - Title case transform applied to figure titles by some themes.
Functions§
- bode
- Render a Bode plot — magnitude (dB, log-x) on top, phase (degrees,
log-x) on the bottom — as a stacked two-panel SVG.
omegasare angular frequencies;mag_dbandphase_degare pre-computed. - boxplot_
stats - equirect
- Equirectangular / plate carrée — degree-for-degree pass-through.
- format_
lat - Format a latitude value with N/S suffix.
- format_
lon - Format a longitude value with E/W suffix.
- gamma_
from_ z - Convert normalized impedance
(r, x)to reflection coefficient(Re Γ, Im Γ). - graticule
- Generates graticule polylines (meridians + parallels) over the given
lon/lat range. Returns a vector of
(xs, ys)tuples in degrees — each is one full meridian or parallel ready to be added as a line series. - mercator
- Project
(lon, lat)in degrees through Mercator. Latitudes are clamped to ±85.051° to avoid infinity at the poles. - multi_
panel - Compose
figuresinto a single SVG. Each panel is rendered at its native viewBox and placed into a nested<svg>. - normal_
quantile - Inverse standard-normal CDF (probit). Beasley-Springer / Moro approximation; ~1e-9 accurate across the usual range.
- polar_
circle - Returns
(thetas, rs)tracing a full circle of radiusr. Useful for concentric reference rings on a polar plot. - polar_
from_ xy - Inverse of
project: Cartesian →(θ, r). - polar_
project - Project
(θ, r)(polar, radians) to(x, y)(Cartesian). - qq_plot
- Returns a Q-Q plot — sample quantiles vs theoretical quantiles of
the standard normal — as a fully-built
Figure. Withreferenceenabled (default), draws ay = xreference line. - quantile
- Linearly-interpolated quantile (R’s “type 7” / NumPy default).
pis in[0, 1]. Empty input returns 0. - smith_
r_ circle - Full circle of constant normalized resistance
rin Γ space. Center(r/(r+1), 0), radius1/(r+1). Tangent to the unit disk at(1, 0). - smith_
x_ arc - Full circle of constant reactance
x. Center(1, 1/x), radius1/|x|. Only the portion inside the unit disk is meaningful — the figure’s circle clip masks the rest. - z_
from_ gamma - Inverse:
(Γ_re, Γ_im)to(r, x). Returns(NAN, NAN)at Γ = 1.