lichtung-plot-ndarray 0.3.0

Direct scientific plotting from logical ndarray views and columns
Documentation

lichtung-plot-ndarray

Plot logical ndarray views directly, with the complete native renderer API re-exported unchanged. The standalone renderer does not depend on this adapter. Strided, reversed, transposed, Fortran and broadcast views need no contiguous intermediate.

use lichtung_plot_ndarray as nd;
use ndarray::array;

fn main() -> Result<(), nd::AdapterError> {
    let table = array![[0., 1., 4.], [5., 2., 5.], [20., 3., 6.]];
    let plot = nd::Line::from_data(table.view(), 0, [1, 2])?
        .column_labels(["Control", "Treated"])?
        .x_label("Time (h)");
    let _native: nd::Plot<nd::kind::Line> = plot.into();
    Ok(())
}

All 25 families have direct new and source-bound from_data constructors. The latter retains a safe read-only array descriptor for later logical-column lookup; .into() releases it and moves the owned native plot. Direct vectors and matrices are snapshotted immediately and do not become implicit lookup sources.

The native Recipe API retains actual ndarray selectors and collection relationships. For a source-bound plot named data, rebind a captured declaration using plot.get_recipe()?.build_with([("data", table.view())])?. Use the shared native recipe::Bindings for independent typed sources; the returned figure owns its values without extending array borrows.

  • ColumnProjection::new(original_shape, &[(original_index, &one_column_source)]) borrows only supplied columns while preserving original bounds and selections. Optional .with_identities(...) transports raw field identities independently of positions and display labels; identity-only entries do not supply values.
  • One-dimensional views bind variables; usize selects a logical source column.
  • Explicit many-y matrices/index collections preserve actual x. indexed and column-distribution methods deliberately choose omitted-coordinate meanings.
  • Heatmap::new(view2) binds a grid; records(x, y, fill) binds explicit cells. Matrix::new(view2) instead treats columns as scatter-matrix variables.
  • (values.view(), present.view()) binds exact-shape validity: true = present. Highlights and unique per-cell IDs are separate same-shape inputs.
  • Row/cell/generated-column facets and roles, supplied bounds, bar sample/estimate modes, independent point layers, statuses, native alpha mappings and independent significance results bind directly without public data-role wrappers.
  • Histogram geometry(lower, upper, height, stat) binds supplied bin heights. Add kde or rug, with separate _from_data forms for each component. Raincloud geometry / geometry_with_hue bind complete summary, density and point columns. Their source forms take the summary source and optional auxiliary sources. Every domain aligns independently; only the main source remains for lookup. Sample Histogram composite_precomputed_kde(x, y) and its independent-source form configure KDE+rug without changing samples, bins or stat.

Numeric primitives round normally to f64. Null is not NaN; raw categories remain strings and exact IDs never pass through f64. Binding does not sort, drop, aggregate, impute or infer statistics. Native families retain their scientific policies and errors. Root Error/Result are native; binding returns standard Result<_, AdapterError>, with lossless native-error conversion for ?.

Run the self-contained masked, strided synthetic heatmap:

cargo run --locked --offline -p lichtung-plot-ndarray --example strided_heatmap
# Optional: -- path/to/output-directory

This adapter is available on crates.io. See the peer English and Chinese guides and the shared adapter contract.